Skip to content

Commit

Permalink
inspect asdf_standard resources to find supported versions
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Jan 29, 2024
1 parent 7ae2d7e commit 2d1be2b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
11 changes: 2 additions & 9 deletions asdf/_core/_extensions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from asdf.extension import ManifestExtension
from asdf.versioning import supported_versions

from ._converters.complex import ComplexConverter
from ._converters.constant import ConstantConverter
Expand Down Expand Up @@ -37,15 +38,7 @@
]


MANIFEST_URIS = [
"asdf://asdf-format.org/core/manifests/core-1.0.0",
"asdf://asdf-format.org/core/manifests/core-1.1.0",
"asdf://asdf-format.org/core/manifests/core-1.2.0",
"asdf://asdf-format.org/core/manifests/core-1.3.0",
"asdf://asdf-format.org/core/manifests/core-1.4.0",
"asdf://asdf-format.org/core/manifests/core-1.5.0",
"asdf://asdf-format.org/core/manifests/core-1.6.0",
]
MANIFEST_URIS = [f"asdf://asdf-format.org/core/manifests/core-{version}" for version in supported_versions]


EXTENSIONS = [
Expand Down
23 changes: 14 additions & 9 deletions asdf/versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
of the ASDF spec.
"""

import importlib.resources
from functools import total_ordering

import yaml
Expand Down Expand Up @@ -143,15 +144,19 @@ def __hash__(self):
return super().__hash__()


supported_versions = [
AsdfVersion("1.0.0"),
AsdfVersion("1.1.0"),
AsdfVersion("1.2.0"),
AsdfVersion("1.3.0"),
AsdfVersion("1.4.0"),
AsdfVersion("1.5.0"),
AsdfVersion("1.6.0"),
]
def _find_asdf_standard_version_map_versions():
# each version has a map
version_map_filenames = (
importlib.resources.files("asdf_standard") / "resources" / "schemas" / "stsci.edu" / "asdf"
).glob("version_map-*.yaml")
versions = []
for version_map_filename in version_map_filenames:
_, version_string = version_map_filename.with_suffix("").name.split("-", 1)
versions.append(AsdfVersion(version_string))
return sorted(versions)


supported_versions = _find_asdf_standard_version_map_versions()


default_version = AsdfVersion("1.5.0")
Expand Down

0 comments on commit 2d1be2b

Please sign in to comment.