Skip to content

Commit

Permalink
Remove module level imports of module data (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
CPBridge authored Aug 15, 2022
1 parent 548321b commit 366c58a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
17 changes: 10 additions & 7 deletions src/highdicom/_module_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@

from pydicom import Dataset

from highdicom._iods import IOD_MODULE_MAP, SOP_CLASS_UID_IOD_KEY_MAP
from highdicom._modules import MODULE_ATTRIBUTE_MAP
from highdicom._iods import (
IOD_MODULE_MAP,
SOP_CLASS_UID_IOD_KEY_MAP
)


# Allowed values for the type of an attribute
class AttributeTypeValues(Enum):
Expand Down Expand Up @@ -168,6 +161,7 @@ def construct_module_tree(module: str) -> Dict[str, Any]:
dictionary that forms an item in the next level of the tree structure.
"""
from highdicom._modules import MODULE_ATTRIBUTE_MAP
if module not in MODULE_ATTRIBUTE_MAP:
raise AttributeError(f"No such module found: '{module}'.")
tree: Dict[str, Any] = {'attributes': {}}
Expand Down Expand Up @@ -205,6 +199,10 @@ def get_module_usage(
"""
from highdicom._iods import (
IOD_MODULE_MAP,
SOP_CLASS_UID_IOD_KEY_MAP
)
try:
iod_name = SOP_CLASS_UID_IOD_KEY_MAP[sop_class_uid]
except KeyError as e:
Expand Down Expand Up @@ -235,6 +233,11 @@ def is_attribute_in_iod(attribute: str, sop_class_uid: str) -> bool:
specified by the sop_class_uid. False otherwise.
"""
from highdicom._iods import (
IOD_MODULE_MAP,
SOP_CLASS_UID_IOD_KEY_MAP
)
from highdicom._modules import MODULE_ATTRIBUTE_MAP
try:
iod_name = SOP_CLASS_UID_IOD_KEY_MAP[sop_class_uid]
except KeyError as e:
Expand Down
4 changes: 2 additions & 2 deletions src/highdicom/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
)
from highdicom.valuerep import check_person_name
from highdicom.version import __version__
from highdicom._iods import IOD_MODULE_MAP, SOP_CLASS_UID_IOD_KEY_MAP
from highdicom._modules import MODULE_ATTRIBUTE_MAP
from highdicom._module_utils import is_attribute_in_iod


Expand Down Expand Up @@ -289,6 +287,8 @@ def _copy_root_attributes_of_module(
DICOM Module (e.g., ``"General Series"`` or ``"Specimen"``)
"""
from highdicom._iods import IOD_MODULE_MAP, SOP_CLASS_UID_IOD_KEY_MAP
from highdicom._modules import MODULE_ATTRIBUTE_MAP
logger.info(
'copy {}-related attributes from dataset "{}"'.format(
ie, dataset.SOPInstanceUID
Expand Down
4 changes: 2 additions & 2 deletions src/highdicom/legacy/sop.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

from highdicom.base import SOPClass
from highdicom.frame import encode_frame
from highdicom._iods import IOD_MODULE_MAP, SOP_CLASS_UID_IOD_KEY_MAP
from highdicom._modules import MODULE_ATTRIBUTE_MAP


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -60,6 +58,8 @@ def _convert_legacy_to_enhanced(
which instances are provided via `sf_datasets`.
"""
from highdicom._iods import IOD_MODULE_MAP, SOP_CLASS_UID_IOD_KEY_MAP
from highdicom._modules import MODULE_ATTRIBUTE_MAP
try:
ref_ds = sf_datasets[0]
except IndexError:
Expand Down

0 comments on commit 366c58a

Please sign in to comment.