babelizer.render module

Render a new babelized project.

babelizer.render.as_cwd(path: str) Generator[None, None, None][source]

Change directory context.

Parameters:

path (str) – Path-like object to a directory.

babelizer.render.blacken_file(filepath: str) None[source]

Format a Python file with black.

Parameters:

filepath (str) – Path-like object to a Python file.

babelizer.render.prettify_python(path_to_repo: str) None[source]

Format files in babelized project with black.

Parameters:

path_to_repo (str) – Path-like object to babelized project.

babelizer.render.render(plugin_metadata: BabelMetadata, output: str, template: str | None = None, clobber: bool = False, version: str = '0.1', make_pretty: bool = False) str[source]

Generate a babelized library.

Parameters:
  • plugin_metadata (BabelMetadata) – The metadata used to babelize the library.

  • output (str) – Name of the directory that will be the new repository.

  • template (str, optional) – Path (or URL) to the cookiecutter template to use.

  • clobber (bool, optional) – If a like-named repository already exists, overwrite it.

  • version (str, optional) – Version of babelized library.

  • make_pretty (bool, optional) – If black and isort are available, run them over the generated project.

Returns:

Path to babelized library

Return type:

str

Raises:

OutputDirExistsError – Raised if output directory exists and clobber is not set.

babelizer.render.render_plugin_repo(template: str, context: dict[str, Any] | None = None, output_dir: str = '.', clobber: bool = False) str[source]

Render a repository for a pymt plugin.

Parameters:
  • template (str) – Path (or URL) to the cookiecutter template to use.

  • context (dict, optional) – Context for the new repository.

  • output_dir (str, optional) – Name of the directory that will be the new repository.

  • clobber (bool, optional) – If a like-named repository already exists, overwrite it.

Returns:

Absolute path to the newly-created repository.

Return type:

path