CiscoDevNet / ydk-gen

Generate model-driven APIs from YANG models
http://ciscodevnet.github.io/ydk-gen/
Apache License 2.0
137 stars 74 forks source link

Version numbers in bundle resolver to comply with PEP 440 #1007

Closed valeriodigregorio closed 2 years ago

valeriodigregorio commented 4 years ago

YDK-gen tag 0.8.4 produces this error:

./generate.py -v --python --bundle /tmp/tmpc6kf25w3/ydk-models-wireless.json
YDKGEN_HOME not set. Assuming current directory is working directory.
Bundle Translator: Cloning from https://github.com/YangModels/yang.git --> /tmp/tmpaqaxfqew.yang
Bundle Translator: Removing folder /tmp/tmpaqaxfqew.yang
Resolving file tmp3f57l_6d.bundle --> /nobackup/pyats/projects/ydk-gen/gen-api/.cache/bundles
Traceback (most recent call last):
  File "./generate.py", line 492, in <module>
    output_directory = (generator.generate(options.bundle))
  File "/nobackup/pyats/projects/ydk-gen/ydkgen/__init__.py", line 93, in generate
    return self._generate_bundle(description_file)
  File "/nobackup/pyats/projects/ydk-gen/ydkgen/__init__.py", line 123, in _generate_bundle
    curr_bundle, all_bundles = resolver.resolve(tmp_file)
  File "/nobackup/pyats/projects/ydk-gen/ydkgen/resolver/bundle_resolver.py", line 304, in resolve
    root = Bundle(bundle_file, self.cached_models_dir, self.iskeyword)
  File "/nobackup/pyats/projects/ydk-gen/ydkgen/resolver/bundle_resolver.py", line 232, in __init__
    super().__init__(data['bundle'])
  File "/nobackup/pyats/projects/ydk-gen/ydkgen/resolver/bundle_resolver.py", line 84, in __init__
    self._version = Version(*tuple(data['version'].split('.')))
TypeError: __new__() takes 4 positional arguments but 5 were given

/tmp/tmpc6kf25w3/ydk-models-wireless.json was:

{
  "author": "Cisco",
  "copyright": "Cisco",
  "description": "YDK bundle for wireless testing",
  "models": {
    "file": [
      "/absolute_path/Cisco-IOS-XE-wireless-enum-types.yang",
      "/absolute_path/Cisco-IOS-XE-wireless-types.yang",
      "/absolute_path/Cisco-IOS-XE-wireless-wlan-cfg.yang",
      "/absolute_path/cisco-semver.yang"
    ],
    "git": [
      {
        "commits": [
          {
            "file": [
              "standard/ietf/RFC/ietf-inet-types.yang",
              "standard/ietf/RFC/ietf-yang-types.yang"
            ]
          }
        ],
        "url": "https://github.com/YangModels/yang.git"
      }
    ]
  },
  "name": "wireless",
  "version": "17.4.0.20200623001943"
}

I tested this with pep440.is_canonical() and it tells me it's well formed. Same error with the followings:

17.4.0.dev20200702092331
17.4.0.post20200702092331
0.1.5.post1

So looking at PEP 440 format should be:

[N!]N(.N)*[{a|b|rc}N][.postN][.devN]

and I believe there's an error on how the release segment "N(.N)*" is parsed.