card_file
Classes
CardFileDecoder
Bases: Transformer
Decoder performs translation from *.card file to a dictionary.
The translation rules are:
*.card |
Python | Comment |
|---|---|---|
| section | dict[str, dict] |
Top-level keys are sections |
| key-value | dict |
Each item is a sigle kv pair |
| list | list |
Empty or with elements |
| nested list | list[list] |
List of lists |
| string | str |
Unquoted (with chars: -./${}*) and double quoted |
| integer number | int |
--- |
| real number | float |
Including scientific notation |
true/y |
True |
Case insensitive |
false/n |
False |
Case insensitive |
Functions
decode
decode(text: str) -> dict
Decode *.card text into dictionary.
Parameters:
-
(textstr) –content of the
*.cardfile
Returns:
-
dict(dict) –Decoded
*.cardfile
Source code in ipsl_common/modipsl/card_file.py
291 292 293 294 295 296 297 298 299 300 301 | |
CardFileEncoder
Functions
flatten_dict_with_sections
flatten_dict_with_sections(position_map: dict) -> dict
Source code in ipsl_common/modipsl/card_file.py
221 222 223 224 225 226 | |
load
load(buffer: TextIOBase)
Load *.card text/file buffer into dictionary.
Parameters:
-
(bufferTextIOBase) –text or file buffer with the
*.cardfile
Returns:
-
dict–Loaded
*.cardfile
Source code in ipsl_common/modipsl/card_file.py
373 374 375 376 377 378 379 380 381 382 383 384 | |
loads
loads(text: str)
Load *.card file string into dictionary.
Parameters:
-
(textstr) –content of the
*.cardfile
Returns:
-
dict–Loaded
*.cardfile
Source code in ipsl_common/modipsl/card_file.py
387 388 389 390 391 392 393 394 395 396 | |