diff --git a/dicom_standard/extract_attributes.py b/dicom_standard/extract_attributes.py index 5d341bf..d0c357c 100644 --- a/dicom_standard/extract_attributes.py +++ b/dicom_standard/extract_attributes.py @@ -3,9 +3,9 @@ ''' import sys -from . import parse_lib as pl -from . import parse_relations as pr -from .table_utils import table_to_dict +from dicom_standard import parse_lib as pl +from dicom_standard import parse_relations as pr +from dicom_standard.table_utils import table_to_dict COLUMN_TITLES = ['tag', 'name', 'keyword', 'valueRepresentation', 'valueMultiplicity', 'retired'] ATTR_TABLE_ID = 'table_6-1' diff --git a/dicom_standard/extract_ciod_module_data.py b/dicom_standard/extract_ciod_module_data.py index a5706f9..c7d216f 100644 --- a/dicom_standard/extract_ciod_module_data.py +++ b/dicom_standard/extract_ciod_module_data.py @@ -6,9 +6,9 @@ import sys import re -from . import parse_lib as pl -from . import parse_relations as pr -from .table_utils import expand_spans, table_to_dict, stringify_table, tdiv_to_table_list +from dicom_standard import parse_lib as pl +from dicom_standard import parse_relations as pr +from dicom_standard.table_utils import expand_spans, table_to_dict, stringify_table, tdiv_to_table_list CHAPTER_ID = 'chapter_A' TABLE_SUFFIX = re.compile(".*IOD Modules$") diff --git a/dicom_standard/extract_macros.py b/dicom_standard/extract_macros.py index 0489980..23bfa3b 100644 --- a/dicom_standard/extract_macros.py +++ b/dicom_standard/extract_macros.py @@ -9,10 +9,10 @@ from bs4 import BeautifulSoup, Tag -from . import parse_lib as pl -from . import parse_relations as pr -from .table_utils import expand_spans, stringify_table, tdiv_to_table_list, TableListType -from .macro_utils import get_id_from_link, MetadataTableType +from dicom_standard import parse_lib as pl +from dicom_standard import parse_relations as pr +from dicom_standard.table_utils import expand_spans, stringify_table, tdiv_to_table_list, TableListType +from dicom_standard.macro_utils import get_id_from_link, MetadataTableType # Macros and modules require the same metadata and formatting, # so they can share these two functions. diff --git a/dicom_standard/extract_modules_with_attributes.py b/dicom_standard/extract_modules_with_attributes.py index 2f5fcd7..5597976 100644 --- a/dicom_standard/extract_modules_with_attributes.py +++ b/dicom_standard/extract_modules_with_attributes.py @@ -6,9 +6,9 @@ import sys import re -from . import parse_lib as pl -from . import parse_relations as pr -from table_utils import expand_spans, table_to_dict, stringify_table, tdiv_to_table_list +from dicom_standard import parse_lib as pl +from dicom_standard import parse_relations as pr +from dicom_standard.table_utils import expand_spans, table_to_dict, stringify_table, tdiv_to_table_list CHAPTER_ID = 'chapter_C' TABLE_SUFFIX = re.compile("(.*Module Attributes$)|(.*Module Table$)") diff --git a/dicom_standard/extract_sections.py b/dicom_standard/extract_sections.py index d42525b..d492c14 100644 --- a/dicom_standard/extract_sections.py +++ b/dicom_standard/extract_sections.py @@ -2,7 +2,7 @@ import re import os -from .parse_lib import parse_html_file, write_pretty_json +from dicom_standard.parse_lib import parse_html_file, write_pretty_json REFERENCED_IDS_RE = re.compile(r'(sect.*)|(figure.*)|(biblio.*)|(table.*)|(note.*)') diff --git a/dicom_standard/hierarchy_utils.py b/dicom_standard/hierarchy_utils.py index fed7c92..fcec7a0 100644 --- a/dicom_standard/hierarchy_utils.py +++ b/dicom_standard/hierarchy_utils.py @@ -7,7 +7,7 @@ from bs4 import Tag -from . import parse_lib as pl +from dicom_standard import parse_lib as pl def get_hierarchy_markers(name: str) -> str: diff --git a/dicom_standard/macro_utils.py b/dicom_standard/macro_utils.py index fcde600..e5d7ae4 100644 --- a/dicom_standard/macro_utils.py +++ b/dicom_standard/macro_utils.py @@ -8,7 +8,7 @@ from bs4 import BeautifulSoup, Tag -from .hierarchy_utils import get_hierarchy_markers +from dicom_standard.hierarchy_utils import get_hierarchy_markers MetadataTableType = Dict[str, Any] MacrosType = Dict[str, MetadataTableType] diff --git a/dicom_standard/parse_lib.py b/dicom_standard/parse_lib.py index 214d753..8c9ee72 100644 --- a/dicom_standard/parse_lib.py +++ b/dicom_standard/parse_lib.py @@ -10,7 +10,7 @@ from bs4 import BeautifulSoup, NavigableString, Tag -from . import parse_relations as pr +from dicom_standard import parse_relations as pr BASE_DICOM_URL = "http://dicom.nema.org/medical/dicom/current/output/html/" BASE_SHORT_DICOM_SECTION_URL = "http://dicom.nema.org/medical/dicom/current/output/chtml/" @@ -82,9 +82,12 @@ def clean_html(html: str) -> str: ''' parsed_html = BeautifulSoup(html, 'html.parser') top_level_tag = get_top_level_tag(parsed_html) - remove_attributes_from_html_tags(top_level_tag) - remove_empty_children(top_level_tag) - return resolve_relative_resource_urls(str(top_level_tag)) + if isinstance(top_level_tag, NavigableString): + return str(top_level_tag) + else: + remove_attributes_from_html_tags(top_level_tag) + remove_empty_children(top_level_tag) + return resolve_relative_resource_urls(str(top_level_tag)) def get_top_level_tag(parsed_html: BeautifulSoup) -> Tag: diff --git a/dicom_standard/postprocess_mark_references.py b/dicom_standard/postprocess_mark_references.py index bdc7764..b65bf67 100644 --- a/dicom_standard/postprocess_mark_references.py +++ b/dicom_standard/postprocess_mark_references.py @@ -7,7 +7,7 @@ from bs4 import BeautifulSoup -from . import parse_lib as pl +from dicom_standard import parse_lib as pl IGNORED_REFS_RE = re.compile(r'(.*ftp.*)|(.*http.*)|(.*part05.*)|(.*chapter.*)|(.*PS3.*)|(.*DCM.*)|(.*glossentry.*)') diff --git a/dicom_standard/postprocess_save_references.py b/dicom_standard/postprocess_save_references.py index bded53e..e79eae6 100644 --- a/dicom_standard/postprocess_save_references.py +++ b/dicom_standard/postprocess_save_references.py @@ -6,7 +6,7 @@ from bs4 import BeautifulSoup -from . import parse_lib as pl +from dicom_standard import parse_lib as pl def find_reference_html_in_sections(pairs, section_listing): diff --git a/dicom_standard/postprocess_update_reference_links.py b/dicom_standard/postprocess_update_reference_links.py index 7bfb2dc..e18dbef 100644 --- a/dicom_standard/postprocess_update_reference_links.py +++ b/dicom_standard/postprocess_update_reference_links.py @@ -1,6 +1,6 @@ import sys -from . import parse_lib as pl +from dicom_standard import parse_lib as pl def update_sourceurls(module_attr_pairs, references): diff --git a/dicom_standard/preprocess_modules_with_attributes.py b/dicom_standard/preprocess_modules_with_attributes.py index 2a7e6f3..f3b6f88 100644 --- a/dicom_standard/preprocess_modules_with_attributes.py +++ b/dicom_standard/preprocess_modules_with_attributes.py @@ -8,9 +8,9 @@ ''' import sys -from . import parse_lib as pl -from .macro_utils import expand_macro_rows -from .hierarchy_utils import record_hierarchy_for_module +from dicom_standard import parse_lib as pl +from dicom_standard.macro_utils import expand_macro_rows +from dicom_standard.hierarchy_utils import record_hierarchy_for_module def expand_all_macros(module_attr_tables, macros): diff --git a/dicom_standard/process_ciod_module_relationship.py b/dicom_standard/process_ciod_module_relationship.py index 8030998..071de6f 100644 --- a/dicom_standard/process_ciod_module_relationship.py +++ b/dicom_standard/process_ciod_module_relationship.py @@ -4,7 +4,7 @@ ''' import sys -from . import parse_lib as pl +from dicom_standard import parse_lib as pl def define_all_relationships(ciod_module_list): diff --git a/dicom_standard/process_ciods.py b/dicom_standard/process_ciods.py index 180e85f..f7ce9cc 100644 --- a/dicom_standard/process_ciods.py +++ b/dicom_standard/process_ciods.py @@ -4,7 +4,7 @@ ''' import sys -from . import parse_lib as pl +from dicom_standard import parse_lib as pl def ciods_from_extracted_list(ciod_module_list): diff --git a/dicom_standard/process_module_attribute_relationship.py b/dicom_standard/process_module_attribute_relationship.py index 8068631..7aaff17 100644 --- a/dicom_standard/process_module_attribute_relationship.py +++ b/dicom_standard/process_module_attribute_relationship.py @@ -1,6 +1,6 @@ import sys -from . import parse_lib as pl +from dicom_standard import parse_lib as pl def module_attr_relationship_table(module_attr_relationship_list): diff --git a/dicom_standard/process_modules.py b/dicom_standard/process_modules.py index 701c22d..0bc6a8d 100644 --- a/dicom_standard/process_modules.py +++ b/dicom_standard/process_modules.py @@ -4,7 +4,7 @@ ''' import sys -from . import parse_lib as pl +from dicom_standard import parse_lib as pl def modules_from_tables(tables): diff --git a/dicom_standard/table_utils.py b/dicom_standard/table_utils.py index ecca5ae..c3e81e5 100644 --- a/dicom_standard/table_utils.py +++ b/dicom_standard/table_utils.py @@ -6,7 +6,7 @@ from copy import copy from bs4 import Tag -from . import parse_relations as pr +from dicom_standard import parse_relations as pr TableListType = List[List[Tag]]