SpecPrinter
dcmspec.spec_printer.SpecPrinter
Printer for DICOM specification models.
Provides methods to print a SpecModel as a hierarchical tree or as a flat table, using rich formatting for console output. Supports colorized output and customizable logging.
Source code in src/dcmspec/spec_printer.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
__init__(model, logger=None)
Initialize the input handler with an optional logger.
PARAMETER | DESCRIPTION |
---|---|
model
|
An instance of SpecModel.
TYPE:
|
logger
|
Logger instance to use. If None, a default logger is created.
TYPE:
|
Source code in src/dcmspec/spec_printer.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
print_table(colorize=False)
Print the specification model as a flat table to the console.
Traverses the content tree and prints each node's attributes in a flat table, using column headers from the metadata node. Optionally colorizes rows.
PARAMETER | DESCRIPTION |
---|---|
colorize
|
Whether to colorize the output by node depth.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in src/dcmspec/spec_printer.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
print_tree(attr_names=None, attr_widths=None, colorize=False)
Print the specification model as a hierarchical tree to the console.
PARAMETER | DESCRIPTION |
---|---|
attr_names
|
Attribute name(s) to display for each node. If None, only the node's name is displayed. If a string, displays that single attribute. If a list of strings, displays all specified attributes.
TYPE:
|
attr_widths
|
List of widths for each attribute in attr_names. If provided, each attribute will be padded/truncated to the specified width.
TYPE:
|
colorize
|
Whether to colorize the output by node depth.
TYPE:
|
Example
This will nicely align the tag, type, and name values in the tree output:
printer.print_tree(attr_names=["elem_tag", "elem_type", "elem_name"], attr_widths=[11, 2, 64])
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in src/dcmspec/spec_printer.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|