Inspect
cifflow.inspect._lexer
inspect_lexer — pretty-print the lexer token stream for a CIF source.
inspect_lexer(source, *, version=None, file=sys.stdout)
Print the full token stream for source to file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
_Source
|
CIF source: a raw string, a |
required |
version
|
Optional[CifVersion]
|
If None (default), auto-detected from the magic line. |
None
|
file
|
TextIO
|
Output stream (default |
stdout
|
Source code in src/cifflow/inspect/_lexer.py
15 16 17 18 19 20 21 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 | |
cifflow.inspect._parser
inspect_parse + ParseHandler — pretty-print parser events for a CIF source.
ParseHandler
A CifParserEvents implementation that prints every event and error.
Pass an optional inner handler to forward all events after printing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inner
|
Optional[CifParserEvents]
|
Optional downstream handler. All events are forwarded to it after being printed. |
None
|
file
|
TextIO
|
Output stream (default |
stdout
|
show_values
|
bool
|
If False, |
True
|
Source code in src/cifflow/inspect/_parser.py
15 16 17 18 19 20 21 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 129 130 131 132 133 134 135 136 137 138 | |
inspect_parse(source, *, inner=None, file=sys.stdout, show_values=True, show_tokens=True)
Run the full pipeline and print token stream then parser events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
_Source
|
CIF source: a raw string, a |
required |
inner
|
Optional[CifParserEvents]
|
Optional downstream handler to receive all events. |
None
|
file
|
TextIO
|
Output stream (default |
stdout
|
show_values
|
bool
|
Forward to |
True
|
show_tokens
|
bool
|
If True (default), also print the lexer token stream before events. |
True
|
Source code in src/cifflow/inspect/_parser.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
cifflow.inspect._model
inspect_model — pretty-print a CifFile or CIF source string.
inspect_model(source, *, mode='pad', file=sys.stdout, show_values=True, show_tokens=True)
Run the full pipeline through the CIF model and print a summary.
Prints (in order): token stream, parser events, CifFile summary, errors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
_Source
|
CIF source: a raw string, a |
required |
mode
|
str
|
Loop row-count mismatch mode passed to |
'pad'
|
file
|
TextIO
|
Output stream (default |
stdout
|
show_values
|
bool
|
Forward to |
True
|
show_tokens
|
bool
|
If True (default), also print the lexer token stream before events. |
True
|
Source code in src/cifflow/inspect/_model.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
cifflow.inspect._schema
inspect_schema — pretty-print a SchemaSpec derived from a DDLm dictionary.
inspect_schema(source, *, show_ddl=False, file=sys.stdout)
Print a structured summary of a SchemaSpec to file.
source may be:
- A :class:
~cifflow.dictionary.schema.SchemaSpec— used directly. - A :class:
~cifflow.dictionary.loader.DdlmDictionary— schema generated from it. - A
pathlib.Pathto a DDLm dictionary file — loaded via :class:~cifflow.dictionary.loader.DictionaryLoaderwithdirectory_resolver(path.parent)so_import.getdirectives resolve from the same directory. - A raw CIF source string — parsed with no resolver (imports that require external files are silently skipped).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Union[str, Path, SchemaSpec, DdlmDictionary]
|
Dictionary source, a pre-built |
required |
show_ddl
|
bool
|
If |
False
|
file
|
TextIO
|
Output stream. Default |
stdout
|
Source code in src/cifflow/inspect/_schema.py
12 13 14 15 16 17 18 19 20 21 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
cifflow.inspect._ingest
inspect_ingest — trace what happens during CIF ingestion.
TraceEvent
dataclass
One event captured during :func:inspect_ingest.
Attributes:
| Name | Type | Description |
|---|---|---|
kind |
str
|
Category of event. One of:
|
detail |
str
|
Human-readable description of the event. |
block_id |
Optional[str]
|
CIF data-block name where the event occurred, if known. |
table |
Optional[str]
|
DuckDB table name involved, if applicable. |
tag |
Optional[str]
|
CIF tag involved, if applicable. |
Source code in src/cifflow/inspect/_ingest.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
inspect_ingest(cif, db=None, schema=None, *, propagate_fk=False, dataset_id=None, file=None)
Run ingestion, capture events, and pretty-print a diagnostic trace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cif
|
CifFile
|
Parsed |
required |
db
|
DuckDBPyConnection | None
|
Open |
None
|
schema
|
SchemaSpec | None
|
|
None
|
propagate_fk
|
bool
|
Forwarded to |
False
|
dataset_id
|
str | None
|
Forwarded to |
None
|
file
|
Optional[TextIO]
|
Where to write the trace. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
list[TraceEvent]
|
All captured events in occurrence order. |
Source code in src/cifflow/inspect/_ingest.py
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 | |