Modules
schimpy.util.yaml_load module
- class schimpy.util.yaml_load.NamedStringIO(value, name='in_memory.yaml')
Bases:
StringIO
- Attributes:
- closed
encoding
Encoding of the text stream.
errors
The error setting of the decoder or encoder.
- line_buffering
newlines
Line endings translated so far.
Methods
close
(/)Close the IO object.
detach
(/)Separate the underlying buffer from the TextIOBase and return it.
fileno
(/)Return underlying file descriptor if one exists.
flush
(/)Flush write buffers, if applicable.
getvalue
(/)Retrieve the entire contents of the object.
isatty
(/)Return whether this is an 'interactive' stream.
read
([size])Read at most size characters, returned as a string.
readable
(/)Returns True if the IO object can be read.
readline
([size])Read until newline or EOF.
readlines
([hint])Return a list of lines from the stream.
seek
(pos[, whence])Change stream position.
seekable
(/)Returns True if the IO object can be seeked.
tell
(/)Tell the current file position.
truncate
([pos])Truncate size to pos.
writable
(/)Returns True if the IO object can be written.
write
(s, /)Write string to file.
writelines
(lines, /)Write a list of lines to stream.
- schimpy.util.yaml_load.csv_from_file(filename, envvar=None, **kwargs)
Load a CSV file and substitute environment variables in string fields.
- Parameters:
- filenamestr
Path to the CSV file.
- envvardict, optional
Dictionary of variables to substitute (e.g., {‘calsim_dss’: ‘blah.dss’}).
- kwargspassed to pd.read_csv
- Returns:
- pd.DataFrame
DataFrame with substitutions applied.
- schimpy.util.yaml_load.yaml_from_dict(input_dict, envvar=None)
Convert a dictionary to a YAML string with environment variable substitution.
- Parameters:
- input_dictdict
The dictionary to convert to YAML.
- envvardict, optional
Environment variables to substitute in the YAML output.
- Returns:
- str
The YAML representation of the dictionary.
- schimpy.util.yaml_load.yaml_from_file(filename, envvar=None)
Load a YAML file and return its contents.
- Parameters:
- filenamestr|Path
The path to the YAML file.
- Returns:
- dict
The contents of the YAML file as a dictionary.
- schimpy.util.yaml_load.yaml_to_yaml(infile, outfile, envvar=None)
Load a YAML file and write its contents to another YAML file.
- Parameters:
- infilestr|Path
The path to the input YAML file.
- outfilestr|Path
The path to the output YAML file.
- envvardict, optional
Environment variables to substitute in the YAML file.