class CustomFlowType(types.CustomType): version = '1.1.0' supported_versions = [(1, 0, 0), versioning.AsdfSpec('>=1.1.0')] name = 'custom_flow' organization = 'nowhere.org' standard = 'custom' types = [CustomFlow] @classmethod def from_tree(cls, tree, ctx): # Convert old schema to new CustomFlow type if cls.version == '1.0.0': return CustomFlow(c=tree['a'], d=tree['b']) else: return CustomFlow(**tree) @classmethod def to_tree(cls, data, ctx): if cls.version == '1.0.0': return dict(a=data.c, b=data.d) else: return dict(c=data.c, d=data.d)
class TestType5(asdftypes.CustomType): supported_versions = \ [versioning.AsdfSpec('<1.0.0'), versioning.AsdfSpec('>=2.0.0')]
class TestType3(asdftypes.CustomType): # This doesn't make much sense, but it's just for the sake of example supported_versions = ['1.0.0', versioning.AsdfSpec('>=2.0.0')]
class TestType0(asdftypes.CustomType): supported_versions = versioning.AsdfSpec('>=1.2.0')