Common utilities.
parselglossy.utils.
ComplexEncoder
(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]¶Bases: json.encoder.JSONEncoder
JSON encoder for complex numbers.
default
(obj)[source]¶Implement this method in a subclass such that it returns
a serializable object for o
, or calls the base implementation
(to raise a TypeError
).
For example, to support arbitrary iterators, you could implement default like this:
def default(self, o):
try:
iterable = iter(o)
except TypeError:
pass
else:
return list(iterable)
# Let the base class default method raise the TypeError
return JSONEncoder.default(self, o)
parselglossy.utils.
default_outfile
(*, fname: Union[str, pathlib.Path], suffix: str) → str[source]¶Default name for output file.
Parameters: |
|
---|---|
Returns: | |
Return type: | The name of the output file. |
parselglossy.utils.
falsey
= ['FALSE', 'OFF', 'NO', 'N']¶List of false-like values.
Type: | List[str] |
---|
parselglossy.utils.
location_in_dict
()[source]¶Convert tuple of keys of a JSONDict
to its representation in code.
For example, given ("a", "b", "c")
returns the string user['a']['b']['c']
.
Parameters: |
|
---|---|
Returns: | where |
Return type: | str |
parselglossy.utils.
path_resolver
(f: Union[str, pathlib.Path]) → pathlib.Path[source]¶Resolve a path.
Parameters: | f (Union[str, Path]) – File whose path needs to be resolved. |
---|---|
Returns: | path – File as a Path object. |
Return type: | Path |
Notes
The file will be created if not already existent.
parselglossy.utils.
printable
= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#$%&*+-./:;<>?@^_|~'¶Custom printable character set.
The printable character set is the standard set in string.printable minus “’(),=[]`{} and all whitespace characters.
Type: | str |
---|
parselglossy.utils.
read_yaml_file
(file_name: pathlib.Path) → Dict[str, Any][source]¶Reads a YAML file and returns it as a dictionary.
Parameters: | file_name (Path) – Path object for the YAML file. |
---|---|
Returns: | d – A dictionary with the contents of the YAML file. |
Return type: | JSONDict |
parselglossy.utils.
truthy
= ['TRUE', 'ON', 'YES', 'Y']¶List of true-like values.
Type: | List[str] |
---|