diff options
author | Szymon Dompke <szymon.dompke@intel.com> | 2021-08-11 20:46:31 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2021-08-17 00:13:43 +0300 |
commit | d699cf969aea5a059b95151f58e054c928f076cc (patch) | |
tree | 1b41a27448e6e2978e81cbf7204a519dfcc283b8 | |
parent | dc414b50c19bea912babb00cf8f1e090dbbcc3b7 (diff) | |
download | bmcweb-d699cf969aea5a059b95151f58e054c928f076cc.tar.xz |
Fix update_schemas script
Script update_schemas.py was incorrectly generating schemas since change
f395daac96c8122623700c2b124d905266ea8223. This was caused by treating
'edm' as 'edmx' during parse process.
Additionally, glob pattern was incorrectly skipping all files starting
with letter 'O', instead of 'Oem' phrase. This lead to python exceptions
during generation, as the script was trying to recreate existing
directories like 'OperatingConfig'.
Unused imports were removed.
Tested:
- running update_schemas.py no longer generates malformed data and no
exception were thrown.
- all files generated by update_schemas.py are generated identically as
before regression.
Signed-off-by: Szymon Dompke <szymon.dompke@intel.com>
Change-Id: I5e2025ec8b264a38cbf5bb944142c83c0486ce50
-rwxr-xr-x | scripts/update_schemas.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/scripts/update_schemas.py b/scripts/update_schemas.py index 3ce4173965..dd39278e4b 100755 --- a/scripts/update_schemas.py +++ b/scripts/update_schemas.py @@ -3,12 +3,9 @@ import requests import zipfile from io import BytesIO import os -from collections import defaultdict from collections import OrderedDict -from distutils.version import StrictVersion import shutil import json -import glob import xml.etree.ElementTree as ET @@ -134,12 +131,15 @@ zipBytesIO = BytesIO(r.content) zip_ref = zipfile.ZipFile(zipBytesIO) # Remove the old files +skip_prefixes = ('Oem') if os.path.exists(schema_path): - files = glob.glob(os.path.join(schema_path, '[!Oem]*')) + files = [os.path.join(schema_path, f) for f in os.listdir(schema_path) + if not f.startswith(skip_prefixes)] for f in files: os.remove(f) if os.path.exists(json_schema_path): - files = glob.glob(os.path.join(json_schema_path, '[!Oem]*')) + files = [os.path.join(json_schema_path, f) for f in + os.listdir(json_schema_path) if not f.startswith(skip_prefixes)] for f in files: if (os.path.isfile(f)): os.remove(f) @@ -183,10 +183,11 @@ with open(metadata_index_path, 'w') as metadata_index: content = content.replace(b'\r\n', b'\n') xml_root = ET.fromstring(content) edmx = "{http://docs.oasis-open.org/odata/ns/edmx}" + edm = "{http://docs.oasis-open.org/odata/ns/edm}" for edmx_child in xml_root: if edmx_child.tag == edmx + "DataServices": for data_child in edmx_child: - if data_child.tag == edmx + "Schema": + if data_child.tag == edm + "Schema": namespace = data_child.attrib["Namespace"] if namespace.startswith("RedfishExtensions"): metadata_index.write( |