io
Functions for handling input/output operations.
Classes¶
Functions¶
deserialize_composition
¶
deserialize_composition(
composition_info: List[dict],
local_path: Optional[Path] = None,
**kwargs
) -> Composition
Deserialize a composition from output.
deserialize_layer
¶
deserialize_layer(
layer_info: dict,
local_path: Optional[Path] = None,
**kwargs: Any
) -> LayerConfig
Deserialize a layer configuration from a rendered layer.
deserialize_rendered_composition
¶
deserialize_rendered_composition(
composition_info: List[dict], location: Path
) -> RenderedComposition
Deserialize a rendered composition from output.
deserialize_rendered_layer
¶
deserialize_rendered_layer(
rendered_layer_info: dict, location: Path
) -> RenderedLayer
Deserialize a rendered layer from output.
Parameters:
rendered_layer_info
-
A dictionary containing the rendered layer information
TYPE:
dict
location
-
The location of the rendered layer, typically the parent directory of the parent directory of the .composition.yaml file
TYPE:
Path
Returns:
-
RenderedLayer
-
A rendered layer object
get_composition_from_path_or_url
¶
get_composition_from_path_or_url(
path_or_url: str,
checkout: Optional[str] = None,
default_config: bool = False,
directory: Optional[str] = None,
no_input: bool = False,
output_dir: Optional[Path] = None,
overwrite_if_exists: bool = False,
skip_if_file_exists: bool = False,
initial_context: Optional[
MutableMapping[str, Any]
] = None,
) -> Composition
Generate a Composition from a path or URL.
Parameters:
path_or_url
-
The path or url to the composition file or template
TYPE:
str
checkout
-
The branch, tag or commit to check out after git clone
DEFAULT:
None
default_config
-
Do not load a config file. Use the defaults instead
TYPE:
bool
DEFAULT:
False
directory
-
Directory within repo that holds cookiecutter.json file
DEFAULT:
None
no_input
-
If
True
force each layer’sno_input
attribute toTrue
TYPE:
bool
DEFAULT:
False
output_dir
-
Where to generate the project
DEFAULT:
None
overwrite_if_exists
-
Overwrite the contents of the output directory if it already exists
TYPE:
bool
DEFAULT:
False
skip_if_file_exists
-
Skip the files in the corresponding directories if they already exist
TYPE:
bool
DEFAULT:
False
initial_context
-
The initial context for the composition
TYPE:
Optional[MutableMapping[str, Any]]
DEFAULT:
None
Returns:
-
Composition
-
The composition object.
is_composition_file
¶
is_composition_file(path_or_url: Union[str, Path]) -> bool
read_composition
¶
read_composition(
path_or_url: Union[str, Path], **kwargs: Any
) -> Composition
Read a YAML file and return a Composition.
Parameters:
path_or_url
-
The location of the configuration file
**kwargs
-
Additional keyword arguments passed to the composition
TYPE:
Any
DEFAULT:
{}
Returns:
-
Composition
-
A composition
read_rendered_composition
¶
read_rendered_composition(
path: Path,
) -> RenderedComposition
Read a .composition.yaml
from a rendered project.
Parameters:
path
-
The path to the .composition.yaml file to read
TYPE:
Path
Returns:
-
RenderedComposition
-
The rendered composition information
read_yaml
¶
read_yaml(path_or_url: Union[str, Path]) -> List[dict]
Read a YAML file and return a list of dictionaries.
serialize_composition
¶
serialize_composition(
layers: List[LayerConfig],
) -> List[dict]
Serialize a composition for output.
serialize_layer
¶
serialize_layer(layer: LayerConfig) -> dict
Serialize the layer configuration for outputting in a rendered layer.
serialize_rendered_composition
¶
serialize_rendered_composition(
composition: RenderedComposition,
) -> List[dict]
Serialize a rendered composition for output.
serialize_rendered_layer
¶
serialize_rendered_layer(
rendered_layer: RenderedLayer,
) -> dict
Serialize a rendered layer for output.
write_rendered_composition
¶
write_rendered_composition(
composition: RenderedComposition,
) -> None
Write the composition file using the rendered layers to the appropriate place.
Parameters:
composition
-
The rendered composition object to export
TYPE:
RenderedComposition