babelizer package

Submodules

babelizer.cli module

exception babelizer.cli.BabelizerAbort(message)

Bases: click.exceptions.Abort

babelizer.cli.err(message: Optional[Any] = None, file: Optional[IO] = None, nl: bool = True, *, err: bool = True, color: Optional[bool] = None, **styles) → None

This function combines echo() and style() into one call. As such the following two calls are the same:

click.secho('Hello World!', fg='green')
click.echo(click.style('Hello World!', fg='green'))

All keyword arguments are forwarded to the underlying functions depending on which one they go with.

Non-string types will be converted to str. However, bytes are passed directly to echo() without applying style. If you want to style bytes that represent text, call bytes.decode() first.

Changed in version 8.0: A non-string message is converted to a string. Bytes are passed through without style applied.

New in version 2.0.

babelizer.cli.out(message: Optional[Any] = None, file: Optional[IO] = None, nl: bool = True, *, err: bool = True, color: Optional[bool] = None, **styles) → None

This function combines echo() and style() into one call. As such the following two calls are the same:

click.secho('Hello World!', fg='green')
click.echo(click.style('Hello World!', fg='green'))

All keyword arguments are forwarded to the underlying functions depending on which one they go with.

Non-string types will be converted to str. However, bytes are passed directly to echo() without applying style. If you want to style bytes that represent text, call bytes.decode() first.

Changed in version 8.0: A non-string message is converted to a string. Bytes are passed through without style applied.

New in version 2.0.

babelizer.cli.yes(text: str, default: Optional[bool] = False, abort: bool = False, prompt_suffix: str = ': ', *, show_default: bool = True, err: bool = True) → bool

Prompts for confirmation (yes/no question).

If the user aborts the input by sending a interrupt signal this function will catch it and raise a Abort exception.

Parameters:
  • text – the question to ask.
  • default – The default value to use when no input is given. If None, repeat until input is given.
  • abort – if this is set to True a negative answer aborts the exception by raising Abort.
  • prompt_suffix – a suffix that should be added to the prompt.
  • show_default – shows or hides the default value in the prompt.
  • err – if set to true the file defaults to stderr instead of stdout, the same as with echo.

Changed in version 8.0: Repeat until input is given if default is None.

New in version 4.0: Added the err parameter.

babelizer.errors module

exception babelizer.errors.BabelizeError(message)

Bases: Exception

exception babelizer.errors.OutputDirExistsError(message)

Bases: babelizer.errors.BabelizeError

exception babelizer.errors.RenderError(message)

Bases: babelizer.errors.BabelizeError

exception babelizer.errors.ScanError(message)

Bases: babelizer.errors.BabelizeError

exception babelizer.errors.SetupPyError(message)

Bases: babelizer.errors.BabelizeError

exception babelizer.errors.ValidationError(message)

Bases: babelizer.errors.BabelizeError

babelizer.metadata module

class babelizer.metadata.BabelMetadata(library=None, build=None, package=None, info=None, plugin=None, ci=None)

Bases: object

LOADERS = {'toml': <function parse>, 'yaml': <function safe_load>}
as_cookiecutter_context()
dump(fp, fmt='yaml')
format(fmt='yaml')
format_toml()
format_yaml()
classmethod from_path(filepath)
classmethod from_stream(stream, fmt='yaml')
get(section, value)
static norm(config)
static parse_entry_point(specifier)

Parse an entry point specifier into its parts.

Parameters:specifier (str) – An entry-point specifier.
Returns:The parts of the entry point as (name, module, class).
Return type:tupe of str
Raises:ValidationError – If the entry point cannot be parsed.

Examples

>>> from babelizer.metadata import BabelMetadata
>>> BabelMetadata.parse_entry_point("Foo=bar:Baz")
('Foo', 'bar', 'Baz')
>>> BabelMetadata.parse_entry_point("bar:Baz")
Traceback (most recent call last):
,,,
babelizer.errors.ValidationError: bad entry point specifier (bar:Baz). specifier must be of the form name=module:class
static validate(config)
babelizer.metadata.validate_dict(meta, required=None, optional=None)

babelizer.render module

babelizer.render.as_cwd(path)
babelizer.render.blacken_file(filepath)
babelizer.render.prettify_python(path_to_repo)
babelizer.render.render(plugin_metadata, output, template=None, clobber=False, version='0.1')
babelizer.render.render_plugin_repo(template, context=None, output_dir='.', clobber=False)

Render a repository for a pymt plugin.

Parameters:
  • template (bool) – Path (or URL) to the cookiecutter template to use.
  • context (dict, optional) – Context for the new repository.
  • output_dir (str, optional) – Name of the folder 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

babelizer.utils module

babelizer.utils.execute(args)
babelizer.utils.get_setup_py_version()
babelizer.utils.save_files(files)
babelizer.utils.setup_py(*args)

babelizer.wrap module

babelizer.wrap.render(language, context=None, output_dir=None, no_input=True, overwrite_if_exists=False)

Module contents