Utilities#

class project_composer.utils.tree_printer.TreePrinter(printable=False)[source]#

Bases: object

Shortcut to make tree row output.

This is useful to display a tree without a real tree implementation.

It allows to display tree rows each one after one. However this technique is not very smart and so you need to give it a pattern that it will correctly pad and translate to the right glyphs.

Usage example:

treeprint = TreePrinter()

treeprint("Plop")
>>>Plop
treeprint("T", "Plap")
>>>├──Plap
treeprint("T", "Plip")
>>>├──Plip
treeprint("IT", "Ping")
>>>│  ├──Ping
treeprint("IIX", "Zip")
>>>│  │  └──Zip
treeprint("IIOT", "Zap")
>>>│  │     └──Zap
treeprint("IIOIT", "Yyyy")
>>>│  │        ├──Yyyy
treeprint("IIOIX", "Zzzz")
>>>│  │        └──Zzzz
treeprint("IIOX", "Zup")
>>>│  │     └──Zup
treeprint("IX", "Pong")
>>>│  └──Pong
treeprint("X", "Plop")
>>>└──Plop
build(*args, **kwargs)[source]#

Build the ascii row for given content.

Parameters:

*args – Either just the content without pattern. Or the pattern then the content.

Returns:

The ascii row glyphs followed by given content.

Return type:

string

get_indent(pattern, yes_or_no=None)[source]#

Convert a pattern to an ascii tree row

  • “T” is for an intersection part, when the current item have sibling;

  • “X” is for an end part, when current item have no sibling;

  • “O” is for a void part, when there is parent level without sibling;

  • “I” is for a pipe part, when there is parent with sibling;

Parameters:

pattern (string) – A pattern composed of letters used to determined the ascii representation to append to output.

Keyword Arguments:

yes_or_no (boolean) – If True use YESLINE_CHAR, if false use NOLINE_CHAR and finally if None (default) use LINE_CHAR for intersection and end parts.

Returns:

Ascii representation of pattern.

Return type:

string

class project_composer.utils.encoding.ExtendedJsonEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]#

Bases: JSONEncoder

Extended JSON encoder to support more basic and internal object types.

Sample usage:

import json
json.dumps({}, indent=4, cls=ExtendedJsonEncoder)
default(obj)[source]#

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
project_composer.utils.tests.debug_invoke(result, caplog=None)[source]#

Output important informations on Click invoke result and optionally caplog.

It invoke command has raised an exception, raise it up.

project_composer.utils.tests.dump_datasets(basedir, source_name, source, result, resolved_payload)[source]#

A helper function to dump source and resolving result lists in JSON files.