dcmspec 0.2.1__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dcmspec-0.2.3/CHANGELOG.md +51 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/PKG-INFO +5 -2
- {dcmspec-0.2.1 → dcmspec-0.2.3}/README.md +4 -1
- {dcmspec-0.2.1 → dcmspec-0.2.3}/pyproject.toml +12 -18
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/apps/ui/iod_explorer/iod_explorer.py +40 -40
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/csv_table_spec_parser.py +16 -7
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/doc_handler.py +15 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/dom_table_spec_parser.py +9 -9
- dcmspec-0.2.1/CHANGELOG.md +0 -29
- {dcmspec-0.2.1 → dcmspec-0.2.3}/LICENSE +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/.DS_Store +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/__init__.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/apps/.DS_Store +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/apps/__init__.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/apps/cli/__init__.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/apps/cli/dataelements.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/apps/cli/iodattributes.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/apps/cli/iodmodules.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/apps/cli/modattributes.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/apps/cli/tdwiicontent.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/apps/cli/uidvalues.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/apps/cli/upsdimseattributes.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/apps/cli/upsioddimseattributes.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/apps/ui/iod_explorer/README.md +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/apps/ui/iod_explorer/__init__.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/apps/ui/iod_explorer/config/README.md +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/apps/ui/iod_explorer/config/iod_explorer_config.json +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/apps/ui/iod_explorer/config/iod_explorer_config_debug.json +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/apps/ui/iod_explorer/config/iod_explorer_config_example.json +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/apps/ui/iod_explorer/config/iod_explorer_config_minimal_logging.json +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/config.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/dom_utils.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/iod_spec_builder.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/iod_spec_printer.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/json_spec_store.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/module_registry.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/pdf_doc_handler.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/progress.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/service_attribute_defaults.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/service_attribute_model.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/spec_factory.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/spec_merger.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/spec_model.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/spec_parser.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/spec_printer.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/spec_store.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/ups_xhtml_doc_handler.py +0 -0
- {dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/xhtml_doc_handler.py +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Release Notes
|
|
2
|
+
|
|
3
|
+
These release notes summarize key changes, improvements, and breaking updates for each version of **dcmspec**.
|
|
4
|
+
|
|
5
|
+
## [0.2.3] - 2025-09-29
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Hotfix: Force UTF-8 decoding for DICOM standard XHTML downloads to prevent mojibake when server omits charset ([#85](https://github.com/dwikler/dcmspec/issues/85)).
|
|
10
|
+
- Hotfix: Add missing `progress_observer` argument to `CSVTableSpecParser.parse` for interface compatibility and to prevent `TypeError` when used with `SpecFactory` ([#86](https://github.com/dwikler/dcmspec/issues/86)).
|
|
11
|
+
|
|
12
|
+
## [0.2.2] - 2025-09-25
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- Fix CONTRIBUTING.md link in README for PyPI compatibility
|
|
17
|
+
- Remove focus border and misleading text cursor in iod-explorer details panel
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Update README: add PyPI and Python version badges
|
|
22
|
+
- Replace Unicode ▶ with ASCII > in status bar for compatibility
|
|
23
|
+
- Improve DICOM Modules usage condition parsing using regex for robustness to missing spaces
|
|
24
|
+
- Add PR template to remind contributors to check the target branch and check tests and docs were updated
|
|
25
|
+
- Move detailed table parsing logs to DEBUG level for less verbose INFO output
|
|
26
|
+
|
|
27
|
+
## [0.2.1] - 2025-09-19
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- Sanitize node and attribute names to remove "/" in DOMTableSpecParser ([#56](https://github.com/dwikler/dcmspec/issues/56))
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
|
|
35
|
+
- Major project restructure: move CLI and UI apps to new `apps/cli` and `apps/ui` folders
|
|
36
|
+
- Improve installation instructions and documentation
|
|
37
|
+
- Prepare and publish the package to [PyPI](https://pypi.org/project/dcmspec/)
|
|
38
|
+
|
|
39
|
+
## [0.2.0] - 2025-09-13
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
|
|
43
|
+
- **Breaking change:** `IODSpecBuilder.build_from_url` now returns a tuple `(iod_model, module_models)` instead of just the IOD model. All callers must be updated to unpack the tuple
|
|
44
|
+
- Update CLI and UI applications to support new return value
|
|
45
|
+
- Add registry mode to `IODSpecBuilder` for efficient module model sharing
|
|
46
|
+
|
|
47
|
+
## [0.1.0] - 2025-05-25
|
|
48
|
+
|
|
49
|
+
### Added
|
|
50
|
+
|
|
51
|
+
- Initial release
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dcmspec
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: Toolkit for extracting, parsing, and processing DICOM specifications.
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
License-File: LICENSE
|
|
@@ -43,6 +43,9 @@ Project-URL: Source, https://github.com/dwikler/dcmspec
|
|
|
43
43
|
Description-Content-Type: text/markdown
|
|
44
44
|
|
|
45
45
|
[](https://github.com/dwikler/dcmspec/actions/workflows/test.yml)
|
|
46
|
+
[](https://badge.fury.io/py/dcmspec)
|
|
47
|
+
[](https://pypi.org/project/dcmspec/)
|
|
48
|
+
[](https://doi.org/10.5281/zenodo.17233195)
|
|
46
49
|
|
|
47
50
|
# dcmspec
|
|
48
51
|
|
|
@@ -112,7 +115,7 @@ See [Configuration & Caching](https://dwikler.github.io/dcmspec/configuration/)
|
|
|
112
115
|
|
|
113
116
|
## Contributing
|
|
114
117
|
|
|
115
|
-
See [CONTRIBUTING.md](
|
|
118
|
+
See [CONTRIBUTING.md](https://github.com/dwikler/dcmspec/blob/main/CONTRIBUTING.md) for guidelines and instructions on how to contribute to the project.
|
|
116
119
|
|
|
117
120
|
## Similar Projects
|
|
118
121
|
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
[](https://github.com/dwikler/dcmspec/actions/workflows/test.yml)
|
|
2
|
+
[](https://badge.fury.io/py/dcmspec)
|
|
3
|
+
[](https://pypi.org/project/dcmspec/)
|
|
4
|
+
[](https://doi.org/10.5281/zenodo.17233195)
|
|
2
5
|
|
|
3
6
|
# dcmspec
|
|
4
7
|
|
|
@@ -68,7 +71,7 @@ See [Configuration & Caching](https://dwikler.github.io/dcmspec/configuration/)
|
|
|
68
71
|
|
|
69
72
|
## Contributing
|
|
70
73
|
|
|
71
|
-
See [CONTRIBUTING.md](
|
|
74
|
+
See [CONTRIBUTING.md](https://github.com/dwikler/dcmspec/blob/main/CONTRIBUTING.md) for guidelines and instructions on how to contribute to the project.
|
|
72
75
|
|
|
73
76
|
## Similar Projects
|
|
74
77
|
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "dcmspec"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.3"
|
|
4
4
|
description = "Toolkit for extracting, parsing, and processing DICOM specifications."
|
|
5
|
-
authors = [
|
|
6
|
-
|
|
7
|
-
]
|
|
8
|
-
license = {text = "Apache-2.0"}
|
|
5
|
+
authors = [{ name = "David Wikler", email = "david.wikler@ulb.be" }]
|
|
6
|
+
license = { text = "Apache-2.0" }
|
|
9
7
|
readme = "README.md"
|
|
10
8
|
requires-python = ">=3.10,<4.0"
|
|
11
9
|
keywords = ["DICOM", "python"]
|
|
@@ -51,23 +49,15 @@ pdf = [
|
|
|
51
49
|
gui = ["tkhtmlview (>=0.3.1,<0.4.0)"]
|
|
52
50
|
|
|
53
51
|
[tool.poetry]
|
|
54
|
-
packages = [{include = "dcmspec", from = "src"}]
|
|
55
|
-
include = [
|
|
56
|
-
|
|
57
|
-
"LICENSE",
|
|
58
|
-
"CHANGELOG.md",
|
|
59
|
-
"src/dcmspec/*"
|
|
60
|
-
]
|
|
61
|
-
exclude = [
|
|
62
|
-
"src/dcmspec/tests/*",
|
|
63
|
-
"src/dcmspec/.DS_Store",
|
|
64
|
-
]
|
|
52
|
+
packages = [{ include = "dcmspec", from = "src" }]
|
|
53
|
+
include = ["README.md", "LICENSE", "CHANGELOG.md", "src/dcmspec/*"]
|
|
54
|
+
exclude = ["src/dcmspec/tests/*", "src/dcmspec/.DS_Store"]
|
|
65
55
|
|
|
66
56
|
[tool.poetry.group.dev.dependencies]
|
|
67
57
|
pytest = "^8.3.5"
|
|
68
58
|
pytest-cov = "^6.1.1"
|
|
69
59
|
mkdocs = "^1.6.1"
|
|
70
|
-
mkdocstrings = {extras = ["python"], version = "^0.29.1"}
|
|
60
|
+
mkdocstrings = { extras = ["python"], version = "^0.29.1" }
|
|
71
61
|
mkdocs-material = "^9.6.14"
|
|
72
62
|
|
|
73
63
|
[build-system]
|
|
@@ -87,4 +77,8 @@ iod-explorer = "dcmspec.apps.ui.iod_explorer.iod_explorer:main"
|
|
|
87
77
|
|
|
88
78
|
[tool.ruff]
|
|
89
79
|
line-length = 120
|
|
90
|
-
select = [
|
|
80
|
+
select = [
|
|
81
|
+
"E",
|
|
82
|
+
"F",
|
|
83
|
+
"D",
|
|
84
|
+
] # E includes line-too-long (E501), D includes docstrings checks
|
|
@@ -28,36 +28,6 @@ PART3_TOC_URL = "https://dicom.nema.org/medical/dicom/current/output/chtml/part0
|
|
|
28
28
|
# Canonical DICOM Part 3 HTML URL
|
|
29
29
|
PART3_HTML_URL = "https://dicom.nema.org/medical/dicom/current/output/html/part03.html"
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
class StatusManager:
|
|
33
|
-
"""Handles status bar messaging with consistent logic."""
|
|
34
|
-
|
|
35
|
-
def __init__(self, status_var):
|
|
36
|
-
"""Initialize the StatusManager.
|
|
37
|
-
|
|
38
|
-
Args:
|
|
39
|
-
status_var: A tkinter StringVar or similar object used to update the status bar text.
|
|
40
|
-
|
|
41
|
-
"""
|
|
42
|
-
self.status_var = status_var
|
|
43
|
-
|
|
44
|
-
def show_count_status(self, count: int):
|
|
45
|
-
"""Show count-based status when no selection."""
|
|
46
|
-
message = f"Showing {count} IODs"
|
|
47
|
-
self.status_var.set(message)
|
|
48
|
-
|
|
49
|
-
def show_selection_status(self, title: str, iod_type: str, is_iod: bool = True):
|
|
50
|
-
"""Show selection-based status when item selected."""
|
|
51
|
-
if is_iod:
|
|
52
|
-
self.status_var.set(f"{title} {iod_type} • Click ▶ to expand")
|
|
53
|
-
else:
|
|
54
|
-
self.status_var.set(f"{iod_type}: {title}")
|
|
55
|
-
|
|
56
|
-
def show_loading_status(self, message: str):
|
|
57
|
-
"""Show loading status."""
|
|
58
|
-
self.status_var.set(message)
|
|
59
|
-
|
|
60
|
-
|
|
61
31
|
def load_app_config() -> Config:
|
|
62
32
|
"""Load app-specific configuration with priority search order.
|
|
63
33
|
|
|
@@ -78,8 +48,6 @@ def load_app_config() -> Config:
|
|
|
78
48
|
Config: Configuration object with app-specific settings.
|
|
79
49
|
|
|
80
50
|
"""
|
|
81
|
-
import os
|
|
82
|
-
|
|
83
51
|
# Look for app-specific config file in several locations (highest priority)
|
|
84
52
|
app_config_locations = [
|
|
85
53
|
"iod_explorer_config.json", # Current directory
|
|
@@ -142,6 +110,34 @@ def setup_logger(config: Config) -> logging.Logger:
|
|
|
142
110
|
|
|
143
111
|
return logger
|
|
144
112
|
|
|
113
|
+
class StatusManager:
|
|
114
|
+
"""Handles status bar messaging with consistent logic."""
|
|
115
|
+
|
|
116
|
+
def __init__(self, status_var):
|
|
117
|
+
"""Initialize the StatusManager.
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
status_var: A tkinter StringVar or similar object used to update the status bar text.
|
|
121
|
+
|
|
122
|
+
"""
|
|
123
|
+
self.status_var = status_var
|
|
124
|
+
|
|
125
|
+
def show_count_status(self, count: int):
|
|
126
|
+
"""Show count-based status when no selection."""
|
|
127
|
+
message = f"Showing {count} IODs"
|
|
128
|
+
self.status_var.set(message)
|
|
129
|
+
|
|
130
|
+
def show_selection_status(self, title: str, iod_type: str, is_iod: bool = True):
|
|
131
|
+
"""Show selection-based status when item selected."""
|
|
132
|
+
if is_iod:
|
|
133
|
+
self.status_var.set(f"{title} {iod_type} • Click > to expand")
|
|
134
|
+
else:
|
|
135
|
+
self.status_var.set(f"{iod_type}: {title}")
|
|
136
|
+
|
|
137
|
+
def show_loading_status(self, message: str):
|
|
138
|
+
"""Show loading status."""
|
|
139
|
+
self.status_var.set(message)
|
|
140
|
+
|
|
145
141
|
|
|
146
142
|
class IODExplorer:
|
|
147
143
|
"""Main window for the IOD Explorer application."""
|
|
@@ -207,7 +203,7 @@ class IODExplorer:
|
|
|
207
203
|
y = (screen_height - window_height) // 2
|
|
208
204
|
self.root.geometry(f"{window_width}x{window_height}+{x}+{y}")
|
|
209
205
|
|
|
210
|
-
def setup_ui(self):
|
|
206
|
+
def setup_ui(self):
|
|
211
207
|
"""Set up the user interface."""
|
|
212
208
|
# Create main frame
|
|
213
209
|
main_frame = ttk.Frame(self.root)
|
|
@@ -248,7 +244,7 @@ class IODExplorer:
|
|
|
248
244
|
details_label_header.pack(side=tk.LEFT)
|
|
249
245
|
|
|
250
246
|
# Left frame for treeview
|
|
251
|
-
left_frame = ttk.Frame(left_panel)
|
|
247
|
+
left_frame = ttk.Frame(left_panel) # sourcery skip: extract-duplicate-method
|
|
252
248
|
left_frame.pack(fill=tk.BOTH, expand=True)
|
|
253
249
|
|
|
254
250
|
# Configure grid for treeview area
|
|
@@ -329,11 +325,14 @@ class IODExplorer:
|
|
|
329
325
|
f'</div>'
|
|
330
326
|
),
|
|
331
327
|
width=50,
|
|
332
|
-
height=30
|
|
333
|
-
|
|
328
|
+
height=30,
|
|
329
|
+
highlightthickness=0,
|
|
330
|
+
)
|
|
331
|
+
|
|
334
332
|
self.details_text.grid(row=0, column=0, sticky="nsew")
|
|
335
333
|
self.details_font_family = selected_font # Store for later use
|
|
336
334
|
self.details_font_size = 10
|
|
335
|
+
self.details_text.config(cursor="arrow")
|
|
337
336
|
|
|
338
337
|
# Add scrollbars that match the treeview style
|
|
339
338
|
details_scroll_y = ttk.Scrollbar(right_frame, orient=tk.VERTICAL, command=self.details_text.yview)
|
|
@@ -710,11 +709,12 @@ class IODExplorer:
|
|
|
710
709
|
elif usage.startswith("U"):
|
|
711
710
|
return "User Optional (U)"
|
|
712
711
|
elif usage.startswith("C"):
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
712
|
+
match = re.match(r"^C\s*-?\s*(.*)$", usage)
|
|
713
|
+
condition = match[1].strip() if match and match[1] else ""
|
|
714
|
+
if condition:
|
|
715
|
+
return f"Conditional (C) - {condition}"
|
|
716
716
|
else:
|
|
717
|
-
return "Conditional (C)"
|
|
717
|
+
return "Conditional (C) - Condition not found"
|
|
718
718
|
else:
|
|
719
719
|
return usage
|
|
720
720
|
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
Provides the CSVTableSpecParser class for parsing DICOM specification tables in CSV format,
|
|
4
4
|
converting them into structured in-memory representations using anytree.
|
|
5
5
|
"""
|
|
6
|
-
from typing import Tuple
|
|
6
|
+
from typing import Dict, List, Tuple, Optional
|
|
7
7
|
from anytree import Node
|
|
8
8
|
|
|
9
9
|
from dcmspec.spec_parser import SpecParser
|
|
10
|
+
from dcmspec.progress import ProgressObserver
|
|
10
11
|
|
|
11
12
|
class CSVTableSpecParser(SpecParser):
|
|
12
13
|
"""Base parser for DICOM Specification IHE tables in CSV-like format."""
|
|
@@ -14,10 +15,11 @@ class CSVTableSpecParser(SpecParser):
|
|
|
14
15
|
def parse(
|
|
15
16
|
self,
|
|
16
17
|
table: dict,
|
|
17
|
-
column_to_attr,
|
|
18
|
-
name_attr="elem_name",
|
|
19
|
-
table_id=None,
|
|
20
|
-
include_depth=None,
|
|
18
|
+
column_to_attr: dict,
|
|
19
|
+
name_attr: str = "elem_name",
|
|
20
|
+
table_id: Optional[str] = None,
|
|
21
|
+
include_depth: Optional[int] = None,
|
|
22
|
+
progress_observer: Optional[ProgressObserver] = None,
|
|
21
23
|
) -> Tuple[Node, Node]:
|
|
22
24
|
"""Parse specification metadata and content from a single table dict.
|
|
23
25
|
|
|
@@ -27,11 +29,18 @@ class CSVTableSpecParser(SpecParser):
|
|
|
27
29
|
name_attr (str): The attribute to use for node names.
|
|
28
30
|
table_id (str, optional): Table identifier for model parsing.
|
|
29
31
|
include_depth (int, optional): The depth to which included tables should be parsed.
|
|
32
|
+
progress_observer (Optional[ProgressObserver]):
|
|
33
|
+
Accepted for interface compatibility, but ignored in this parser.
|
|
34
|
+
Included so that this method can be called with the same arguments as other table parsers.
|
|
30
35
|
|
|
31
36
|
Returns:
|
|
32
37
|
tuple: (metadata_node, content_node)
|
|
33
38
|
|
|
34
39
|
"""
|
|
40
|
+
if progress_observer is not None and hasattr(self, "logger"):
|
|
41
|
+
self.logger.debug(
|
|
42
|
+
"Progress reporting is not supported yet for CSV parsing and will be ignored."
|
|
43
|
+
)
|
|
35
44
|
# Use the header and data from the grouped table dict
|
|
36
45
|
header = table.get("header", [])
|
|
37
46
|
data = table.get("data", [])
|
|
@@ -47,8 +56,8 @@ class CSVTableSpecParser(SpecParser):
|
|
|
47
56
|
|
|
48
57
|
def parse_table(
|
|
49
58
|
self,
|
|
50
|
-
tables:
|
|
51
|
-
column_to_attr:
|
|
59
|
+
tables: List[List[List[str]]], # List of tables, each a list of rows (list of str)
|
|
60
|
+
column_to_attr: Dict[int, str],
|
|
52
61
|
name_attr: str = "elem_name",
|
|
53
62
|
) -> Node:
|
|
54
63
|
"""Build a tree from tables using column mapping and '>' nesting logic.
|
|
@@ -94,6 +94,8 @@ class DocHandler:
|
|
|
94
94
|
try:
|
|
95
95
|
with requests.get(url, timeout=30, stream=True, headers={"Accept-Encoding": "identity"}) as response:
|
|
96
96
|
response.raise_for_status()
|
|
97
|
+
self._set_response_encoding(response)
|
|
98
|
+
|
|
97
99
|
total = int(response.headers.get('content-length', 0))
|
|
98
100
|
chunk_size = 8192
|
|
99
101
|
if binary:
|
|
@@ -109,6 +111,19 @@ class DocHandler:
|
|
|
109
111
|
self.logger.error(f"Failed to save file {file_path}: {e}")
|
|
110
112
|
raise RuntimeError(f"Failed to save file {file_path}: {e}") from e
|
|
111
113
|
|
|
114
|
+
def _set_response_encoding(self, response):
|
|
115
|
+
"""Set response.encoding to UTF-8 only if the Content-Type header does not specify a charset.
|
|
116
|
+
|
|
117
|
+
Force utf-8 decoding if the web server does not specify the charset in the HTTP response
|
|
118
|
+
Content-Type header (DICOM standard XHTML files are always UTF-8 encoded).
|
|
119
|
+
"""
|
|
120
|
+
content_type = response.headers.get("Content-Type", "")
|
|
121
|
+
if "charset=" not in content_type.lower():
|
|
122
|
+
response.encoding = "utf-8"
|
|
123
|
+
self.logger.debug("No charset in Content-Type header; forcing UTF-8 decoding.")
|
|
124
|
+
else:
|
|
125
|
+
self.logger.debug(f"Using server-specified encoding from Content-Type: {content_type}")
|
|
126
|
+
|
|
112
127
|
def _report_progress(self, downloaded, total, progress_observer, last_percent):
|
|
113
128
|
"""Report progress if percent changed.
|
|
114
129
|
|
|
@@ -13,7 +13,7 @@ from typing import Any, Dict, Optional, Union
|
|
|
13
13
|
from dcmspec.spec_parser import SpecParser
|
|
14
14
|
|
|
15
15
|
from dcmspec.dom_utils import DOMUtils
|
|
16
|
-
from dcmspec.progress import Progress, ProgressStatus, calculate_percent
|
|
16
|
+
from dcmspec.progress import Progress, ProgressObserver, ProgressStatus, calculate_percent
|
|
17
17
|
|
|
18
18
|
class DOMTableSpecParser(SpecParser):
|
|
19
19
|
"""Parser for DICOM specification tables in XHTML DOM format.
|
|
@@ -43,7 +43,7 @@ class DOMTableSpecParser(SpecParser):
|
|
|
43
43
|
column_to_attr: Dict[int, str],
|
|
44
44
|
name_attr: str,
|
|
45
45
|
include_depth: Optional[int] = None, # None means unlimited
|
|
46
|
-
progress_observer: Optional[
|
|
46
|
+
progress_observer: Optional[ProgressObserver] = None,
|
|
47
47
|
skip_columns: Optional[list[int]] = None,
|
|
48
48
|
unformatted: Optional[Union[bool, Dict[int, bool]]] = True,
|
|
49
49
|
) -> tuple[Node, Node]:
|
|
@@ -59,7 +59,7 @@ class DOMTableSpecParser(SpecParser):
|
|
|
59
59
|
name_attr (str): The attribute name to use for building node names.
|
|
60
60
|
include_depth (Optional[int], optional): The depth to which included tables should be parsed.
|
|
61
61
|
None means unlimited.
|
|
62
|
-
progress_observer (Optional[
|
|
62
|
+
progress_observer (Optional[ProgressObserver]): Optional observer to report parsing progress.
|
|
63
63
|
skip_columns (Optional[list[int]]): List of column indices to skip if the row is missing a column.
|
|
64
64
|
This argument is typically set via `parser_kwargs` when using SpecFactory.
|
|
65
65
|
unformatted (Optional[Union[bool, Dict[int, bool]]]):
|
|
@@ -132,7 +132,7 @@ class DOMTableSpecParser(SpecParser):
|
|
|
132
132
|
name_attr: str,
|
|
133
133
|
table_nesting_level: int = 0,
|
|
134
134
|
include_depth: Optional[int] = None, # None means unlimited
|
|
135
|
-
progress_observer: Optional[
|
|
135
|
+
progress_observer: Optional[ProgressObserver] = None,
|
|
136
136
|
skip_columns: Optional[list[int]] = None,
|
|
137
137
|
visited_tables: Optional[set] = None,
|
|
138
138
|
unformatted_list: Optional[list[bool]] = None,
|
|
@@ -151,7 +151,7 @@ class DOMTableSpecParser(SpecParser):
|
|
|
151
151
|
name_attr: tree node attribute name to use to build node name
|
|
152
152
|
table_nesting_level: The nesting level of the table (used for recursion call only).
|
|
153
153
|
include_depth: The depth to which included tables should be parsed.
|
|
154
|
-
progress_observer (Optional[
|
|
154
|
+
progress_observer (Optional[ProgressObserver]): Optional observer to report parsing progress.
|
|
155
155
|
skip_columns (Optional[list[int]]): List of column indices to skip if the row is missing a column.
|
|
156
156
|
visited_tables (Optional[set]): Set of table IDs that have been visited to prevent infinite recursion.
|
|
157
157
|
unformatted_list (Optional[list[bool]]): List of booleans indicating whether to extract each column as
|
|
@@ -161,7 +161,7 @@ class DOMTableSpecParser(SpecParser):
|
|
|
161
161
|
root: The root node of the tree representation of the specification table.
|
|
162
162
|
|
|
163
163
|
"""
|
|
164
|
-
self.logger.
|
|
164
|
+
self.logger.debug(f"Nesting Level: {table_nesting_level}, Parsing table with id {table_id}")
|
|
165
165
|
|
|
166
166
|
if unformatted_list is None:
|
|
167
167
|
num_columns = max(column_to_attr.keys()) + 1
|
|
@@ -208,7 +208,7 @@ class DOMTableSpecParser(SpecParser):
|
|
|
208
208
|
progress_observer=progress_observer if table_nesting_level == 0 else None,
|
|
209
209
|
)
|
|
210
210
|
|
|
211
|
-
self.logger.
|
|
211
|
+
self.logger.debug(f"Nesting Level: {table_nesting_level}, Table parsed successfully")
|
|
212
212
|
|
|
213
213
|
return root
|
|
214
214
|
|
|
@@ -287,7 +287,7 @@ class DOMTableSpecParser(SpecParser):
|
|
|
287
287
|
unformatted_list: list[bool],
|
|
288
288
|
level_nodes: Dict[int, Node],
|
|
289
289
|
root: Node,
|
|
290
|
-
progress_observer: Optional[
|
|
290
|
+
progress_observer: Optional[ProgressObserver] = None
|
|
291
291
|
) -> None:
|
|
292
292
|
"""Process all rows in the table, handling recursion, nesting, and node creation."""
|
|
293
293
|
rows = table.find_all("tr")[1:]
|
|
@@ -777,7 +777,7 @@ class DOMTableSpecParser(SpecParser):
|
|
|
777
777
|
for col_idx in column_to_attr
|
|
778
778
|
if col_idx < len(cells)
|
|
779
779
|
)
|
|
780
|
-
self.logger.
|
|
780
|
+
self.logger.debug(f"Extracted Header: {header}")
|
|
781
781
|
return header
|
|
782
782
|
|
|
783
783
|
def _clean_extracted_text(self, text: str) -> str:
|
dcmspec-0.2.1/CHANGELOG.md
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# Release Notes
|
|
2
|
-
|
|
3
|
-
These release notes summarize key changes, improvements, and breaking updates for each version of **dcmspec**.
|
|
4
|
-
|
|
5
|
-
## [0.2.1] - 2025-09-19
|
|
6
|
-
|
|
7
|
-
### Fixed
|
|
8
|
-
|
|
9
|
-
- Sanitize node and attribute names to remove "/" in DOMTableSpecParser ([#56](https://github.com/dwikler/dcmspec/issues/56))
|
|
10
|
-
|
|
11
|
-
### Changed
|
|
12
|
-
|
|
13
|
-
- Major project restructure: moved CLI and UI apps to new `apps/cli` and `apps/ui` folders
|
|
14
|
-
- Improved installation instructions and documentation
|
|
15
|
-
- Prepared and published the package to [PyPI](https://pypi.org/project/dcmspec/)
|
|
16
|
-
|
|
17
|
-
## [0.2.0] - 2025-09-13
|
|
18
|
-
|
|
19
|
-
### Changed
|
|
20
|
-
|
|
21
|
-
- **Breaking change:** `IODSpecBuilder.build_from_url` now returns a tuple `(iod_model, module_models)` instead of just the IOD model. All callers must be updated to unpack the tuple.
|
|
22
|
-
- Updated CLI and UI applications to support new return value.
|
|
23
|
-
- Added registry mode to `IODSpecBuilder` for efficient module model sharing.
|
|
24
|
-
|
|
25
|
-
## [0.1.0] - 2025-05-25
|
|
26
|
-
|
|
27
|
-
### Added
|
|
28
|
-
|
|
29
|
-
- Initial release.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dcmspec-0.2.1 → dcmspec-0.2.3}/src/dcmspec/apps/ui/iod_explorer/config/iod_explorer_config.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|