X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=juju%2Fclient%2Ffacade.py;h=c959e01649964a9a5eb955e2fc0829ebabfcc90f;hb=17b26ef759a99c9010ea30e47205bfb332400e74;hp=5f37c27305d957a8689804304ec2dbb553d42462;hpb=1a3cee44420e79fda92943edf636eaddb393145e;p=osm%2FN2VC.git diff --git a/juju/client/facade.py b/juju/client/facade.py index 5f37c27..c959e01 100644 --- a/juju/client/facade.py +++ b/juju/client/facade.py @@ -17,7 +17,6 @@ from . import codegen _marker = object() JUJU_VERSION = re.compile('[0-9]+\.[0-9-]+[\.\-][0-9a-z]+(\.[0-9]+)?') -VERSION_MAP = defaultdict(dict) # Workaround for https://bugs.launchpad.net/juju/+bug/1683906 NAUGHTY_CLASSES = ['ClientFacade', 'Client', 'FullStatus', 'ModelStatusInfo', 'ModelInfo'] @@ -268,7 +267,7 @@ def buildTypes(schema, capture): class {}(Type): _toSchema = {} _toPy = {} - def __init__(self{}{}): + def __init__(self{}{}, **unknown_fields): ''' {} '''""".format( @@ -520,7 +519,10 @@ class Type: if isinstance(data, cls): return data if isinstance(data, str): - data = json.loads(data) + try: + data = json.loads(data) + except json.JSONDecodeError: + raise d = {} for k, v in (data or {}).items(): d[cls._toPy.get(k, k)] = v @@ -716,25 +718,6 @@ def write_client(captures, options): print(factories[key], file=f) -def write_version_map(options): - """ - In order to work around - https://bugs.launchpad.net/juju/+bug/1682925, we build a map of - the facades that each version supports, and write it to disk here. - - """ - with open("{}/version_map.py".format(options.output_dir), "w") as f: - f.write(HEADER) - f.write("VERSION_MAP = {\n") - for juju_version in sorted(VERSION_MAP.keys()): - f.write(' "{}": {{\n'.format(juju_version)) - for key in VERSION_MAP[juju_version]: - f.write(' "{}": {},\n'.format( - key, VERSION_MAP[juju_version][key])) - f.write(' },\n') - f.write("}\n") - - def generate_facades(options): captures = defaultdict(codegen.Capture) schemas = {} @@ -759,7 +742,6 @@ def generate_facades(options): for schema in schemas[juju_version]: schema.buildDefinitions() buildTypes(schema, captures[schema.version]) - VERSION_MAP[juju_version][schema.name] = schema.version # Build the Facade classes for juju_version in sorted(schemas.keys()): @@ -797,7 +779,6 @@ def main(): last_version = write_facades(captures, options) write_definitions(captures, options, last_version) write_client(captures, options) - write_version_map(options) if __name__ == '__main__': main()