Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
import SerializationContext from asdf.extension for version >3
Browse files Browse the repository at this point in the history
braingram committed Mar 22, 2024
1 parent e3fcbbb commit 104dcdf
Showing 3 changed files with 18 additions and 4 deletions.
7 changes: 6 additions & 1 deletion weldx/asdf/types.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,12 @@
import functools
import re

from asdf.asdf import SerializationContext
import asdf

if asdf.__version__ > "3.0.0":
from asdf.extension import SerializationContext
else:
from asdf.asdf import SerializationContext
from asdf.extension import Converter
from asdf.versioning import AsdfSpec
from boltons.iterutils import remap
8 changes: 6 additions & 2 deletions weldx/asdf/util.py
Original file line number Diff line number Diff line change
@@ -11,7 +11,11 @@

import asdf
import pint
from asdf.asdf import SerializationContext

if asdf.__version__ > "3.0.0":
from asdf.extension import SerializationContext
else:
from asdf.asdf import SerializationContext
from asdf.config import AsdfConfig, get_config
from asdf.extension import Extension
from asdf.tagged import TaggedDict, TaggedList, TaggedString
@@ -495,7 +499,7 @@ def from_yaml_tree(

def get_weldx_extension(ctx: SerializationContext | AsdfConfig) -> Extension:
"""Grab the weldx extension from list of current active extensions."""
if isinstance(ctx, asdf.asdf.SerializationContext):
if isinstance(ctx, SerializationContext):
extensions = ctx.extension_manager.extensions
elif isinstance(ctx, asdf.config.AsdfConfig):
extensions = ctx.extensions
7 changes: 6 additions & 1 deletion weldx/tags/base_types.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,12 @@

from uuid import UUID

from asdf.asdf import SerializationContext
import asdf

if asdf.__version__ > "3.0.0":
from asdf.extension import SerializationContext
else:
from asdf.asdf import SerializationContext

from weldx.asdf.types import WeldxConverter

0 comments on commit 104dcdf

Please sign in to comment.