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 |
| range | tuple[int] |
Integer range in the form: START:STEP:END |
| 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 |
Methods:
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
298 299 300 301 302 303 304 305 306 307 308 | |
CardFileEncoder
Functions:
flatten_dict_with_sections
flatten_dict_with_sections(position_map: dict) -> dict
Source code in ipsl_common/modipsl/card_file.py
226 227 228 229 230 231 | |
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
383 384 385 386 387 388 389 390 391 392 393 394 | |
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
397 398 399 400 401 402 403 404 405 406 | |