Enable pycodestyle
This commit allows our python code to be run through the CI format-code
scripts. The exact content is copied from sdbusplus.
Tested, ran pycodeformat on each script, observed it passing.
Ran each script individually. check_base_registry seems broken previous
to this commit, although it provides the same output.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I7eacfa355b794f49308b900c2988809d2aa122c3
diff --git a/scripts/update_schemas.py b/scripts/update_schemas.py
index ade0550..3ce4173 100755
--- a/scripts/update_schemas.py
+++ b/scripts/update_schemas.py
@@ -39,7 +39,7 @@
'EventService',
'IPAddresses',
'JsonSchemaFile',
- 'JsonSchemaFileCollection', #redfish/v1/JsonSchemas
+ 'JsonSchemaFileCollection', # redfish/v1/JsonSchemas
'LogEntry',
'LogEntryCollection',
'LogService',
@@ -69,7 +69,7 @@
'PCIeFunction',
'PCIeFunctionCollection',
'Power',
- 'Privileges', #Used in Role
+ 'Privileges', # Used in Role
'Processor',
'ProcessorCollection',
'RedfishError',
@@ -156,13 +156,14 @@
metadata_index.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
metadata_index.write(
- "<edmx:Edmx xmlns:edmx=\"http://docs.oasis-open.org/odata/ns/edmx\" Version=\"4.0\">\n")
+ "<edmx:Edmx xmlns:edmx="
+ "\"http://docs.oasis-open.org/odata/ns/edmx\""
+ " Version=\"4.0\">\n")
for zip_filepath in zip_ref.namelist():
- if zip_filepath.startswith(VERSION +
- '/csdl/') & (zip_filepath != VERSION +
- "/csdl/") & (zip_filepath != VERSION +
- "/csdl/"):
+ if zip_filepath.startswith(VERSION + '/csdl/') and \
+ (zip_filepath != VERSION + "/csdl/") and \
+ (zip_filepath != VERSION + "/csdl/"):
filename = os.path.basename(zip_filepath)
# filename looks like Zone_v1.xml
@@ -171,7 +172,7 @@
print("excluding schema: " + filename)
continue
- with open(os.path.join(schema_path, filename), 'wb') as schema_file:
+ with open(os.path.join(schema_path, filename), 'wb') as schema_out:
metadata_index.write(
" <edmx:Reference Uri=\"/redfish/v1/schema/" +
@@ -181,29 +182,38 @@
content = zip_ref.read(zip_filepath)
content = content.replace(b'\r\n', b'\n')
xml_root = ET.fromstring(content)
-
+ edmx = "{http://docs.oasis-open.org/odata/ns/edmx}"
for edmx_child in xml_root:
-
- if edmx_child.tag == "{http://docs.oasis-open.org/odata/ns/edmx}DataServices":
+ if edmx_child.tag == edmx + "DataServices":
for data_child in edmx_child:
- if data_child.tag == "{http://docs.oasis-open.org/odata/ns/edm}Schema":
+ if data_child.tag == edmx + "Schema":
namespace = data_child.attrib["Namespace"]
if namespace.startswith("RedfishExtensions"):
metadata_index.write(
- " <edmx:Include Namespace=\"" + namespace + "\" Alias=\"Redfish\"/>\n")
+ " "
+ "<edmx:Include Namespace=\"" +
+ namespace +
+ "\" Alias=\"Redfish\"/>\n"
+ )
else:
metadata_index.write(
- " <edmx:Include Namespace=\"" + namespace + "\"/>\n")
- schema_file.write(content)
+ " "
+ "<edmx:Include Namespace=\""
+ + namespace + "\"/>\n"
+ )
+ schema_out.write(content)
metadata_index.write(" </edmx:Reference>\n")
- metadata_index.write(""" <edmx:DataServices>
- <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="Service">
- <EntityContainer Name="Service" Extends="ServiceRoot.v1_0_0.ServiceContainer"/>
- </Schema>
- </edmx:DataServices>
-""")
+ metadata_index.write(" <edmx:DataServices>\n"
+ " <Schema "
+ "xmlns=\"http://docs.oasis-open.org/odata/ns/edm\" "
+ "Namespace=\"Service\">\n"
+ " <EntityContainer Name=\"Service\" "
+ "Extends=\"ServiceRoot.v1_0_0.ServiceContainer\"/>\n"
+ " </Schema>\n"
+ " </edmx:DataServices>\n"
+ )
# TODO:Issue#32 There's a bug in the script that currently deletes this
# schema (because it's an OEM schema). Because it's the only six, and we
# don't update schemas very often, we just manually fix it. Need a
@@ -214,26 +224,35 @@
metadata_index.write(" </edmx:Reference>\n")
metadata_index.write(
- " <edmx:Reference Uri=\"/redfish/v1/schema/OemComputerSystem_v1.xml\">\n")
- metadata_index.write(" <edmx:Include Namespace=\"OemComputerSystem\"/>\n")
+ " <edmx:Reference Uri=\""
+ "/redfish/v1/schema/OemComputerSystem_v1.xml\">\n")
+ metadata_index.write(
+ " <edmx:Include Namespace=\"OemComputerSystem\"/>\n")
metadata_index.write(" </edmx:Reference>\n")
metadata_index.write(
- " <edmx:Reference Uri=\"/redfish/v1/schema/OemVirtualMedia_v1.xml\">\n")
- metadata_index.write(" <edmx:Include Namespace=\"OemVirtualMedia\"/>\n")
- metadata_index.write(" <edmx:Include Namespace=\"OemVirtualMedia.v1_0_0\"/>\n")
+ " <edmx:Reference Uri=\""
+ "/redfish/v1/schema/OemVirtualMedia_v1.xml\">\n")
+ metadata_index.write(
+ " <edmx:Include Namespace=\"OemVirtualMedia\"/>\n")
+ metadata_index.write(
+ " <edmx:Include Namespace=\"OemVirtualMedia.v1_0_0\"/>\n")
metadata_index.write(" </edmx:Reference>\n")
metadata_index.write(
- " <edmx:Reference Uri=\"/redfish/v1/schema/OemAccountService_v1.xml\">\n")
- metadata_index.write(" <edmx:Include Namespace=\"OemAccountService\"/>\n")
- metadata_index.write(" <edmx:Include Namespace=\"OemAccountService.v1_0_0\"/>\n")
+ " <edmx:Reference Uri=\""
+ "/redfish/v1/schema/OemAccountService_v1.xml\">\n")
+ metadata_index.write(
+ " <edmx:Include Namespace=\"OemAccountService\"/>\n")
+ metadata_index.write(
+ " <edmx:Include Namespace=\"OemAccountService.v1_0_0\"/>\n")
metadata_index.write(" </edmx:Reference>\n")
metadata_index.write(
" <edmx:Reference Uri=\"/redfish/v1/schema/OemSession_v1.xml\">\n")
metadata_index.write(" <edmx:Include Namespace=\"OemSession\"/>\n")
- metadata_index.write(" <edmx:Include Namespace=\"OemSession.v1_0_0\"/>\n")
+ metadata_index.write(
+ " <edmx:Include Namespace=\"OemSession.v1_0_0\"/>\n")
metadata_index.write(" </edmx:Reference>\n")
metadata_index.write("</edmx:Edmx>\n")
@@ -272,7 +291,8 @@
"/redfish/v1/JsonSchemas/" + schema + "/" + schema + ".json")
index_json = OrderedDict()
- index_json["@odata.context"] = "/redfish/v1/$metadata#JsonSchemaFile.JsonSchemaFile"
+ index_json["@odata.context"] = \
+ "/redfish/v1/$metadata#JsonSchemaFile.JsonSchemaFile"
index_json["@odata.id"] = "/redfish/v1/JsonSchemas/" + schema
index_json["@odata.type"] = "#JsonSchemaFile.v1_0_2.JsonSchemaFile"
index_json["Name"] = schema + " Schema File"