Encodings¶
Some Actions, like the Merge action, need to decode a file written in a format, modify data and then encode the data again before writing it back to the file.
Encodings abstract the decoding and encoding part, allowing actions to support many file formats without having to implement each format separately.
Bundled Encodings¶
- class rcmt.encoding.Json(indent=0)¶
Json supports json files.
It uses Python’s json module to decode and encode data.
- class rcmt.encoding.Toml¶
Toml supports files written in Tom’s Obvious, Minimal Language.
- class rcmt.encoding.Yaml(explicit_start=False)¶
Yaml supports yaml files.
It uses PyYAML to decode and encode data.
Base Class¶
- class rcmt.encoding.Encoding¶
Encoding defines the API of each encoding.
- decode(file)¶
decode parses the content of a file-like object.
- Parameters
file (
TextIO
) – File to parse.- Return type
Any
- Returns
Any
- encode(file, data)¶
encode writes data to a file-like object.
- Parameters
file (
TextIO
) – File to write data to.data (
dict
) – Data to write to the file.
- Return type
None
- Returns
None
- merge(repo_data, pkg_data, strategy)¶
merge merges the data from a repository with the data from a package.
- Parameters
repo_data (
Any
) – Data read from a file in a repository.pkg_data (
Any
) – Data read from a file in a package.strategy (
Strategy
) – The strategy to use when merging dicts. Not every encoding needs to support this option.
- Return type
Any
- Returns
Any