pydocmaker.util

Attributes

colors_dc

Classes

bcolors

Create a collection of name/value pairs.

_raise_missing

Functions

txtcolor(s, color)

split_camel_case(st)

flatten_list(lst)

generate_unique_id()

get_page_title(docname)

path2attachment(path, filename)

upload_report_to_redmine(doc, redmine, project_id[, ...])

Uploads a report generated from a Doc object to a Redmine wiki page.

filename2identifier(filename)

Converts a filename to a valid identifier by:

bytes_path_exists(→ bool)

Check if a bytes literal refers to an existing file/directory.

get_inp_context([default_name, context])

Module Contents

class pydocmaker.util.bcolors(*args, **kwds)

Bases: enum.Enum

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

    >>> Color.RED
    <Color.RED: 1>
    
  • value lookup:

    >>> Color(1)
    <Color.RED: 1>
    
  • name lookup:

    >>> Color['RED']
    <Color.RED: 1>
    

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

HEADER = '\x1b[95m'
OKBLUE = '\x1b[94m'
OKCYAN = '\x1b[96m'
OKGREEN = '\x1b[92m'
WARNING = '\x1b[93m'
FAIL = '\x1b[91m'
ENDC = '\x1b[0m'
BOLD = '\x1b[1m'
UNDERLINE = '\x1b[4m'
pydocmaker.util.colors_dc
pydocmaker.util.txtcolor(s: str, color: str)
pydocmaker.util.split_camel_case(st: str)
pydocmaker.util.flatten_list(lst)
pydocmaker.util.generate_unique_id()
pydocmaker.util.get_page_title(docname)
pydocmaker.util.path2attachment(path, filename)
pydocmaker.util.upload_report_to_redmine(doc, redmine, project_id, report_name=None, page_title=None, force_overwrite=False, verb=True)

Uploads a report generated from a Doc object to a Redmine wiki page.

Parameters:
  • doc (Doc) – The Doc object containing the report data.

  • redmine (redminelib.Redmine) – A Redmine connection object.

  • project_id (str) – The ID of the Redmine project where the report should be uploaded.

  • report_name (str, optional) – The name of the report. If not provided, the follwoing schema %Y%m%d_%H%M_exported_report will be used.

  • page_title (str, optional) – The title of the Redmine wiki page. If not provided, it will be derived from the report name.

  • force_overwrite (bool, optional) – Whether to overwrite an existing page with the same title. Defaults to False.

  • verb (bool, optional) – Whether to print verbose output during upload. Defaults to True.

Returns:

The uploaded Redmine wiki page object.

Return type:

redminelib.WikiPage

Raises:

AssertionError – If any of the doc, project_id or redmine arguments is None or empty.

pydocmaker.util.filename2identifier(filename)

Converts a filename to a valid identifier by: 1. Stripping the file extension 2. Replacing any non-alphanumeric character with an underscore 3. Ensuring it doesn’t start with a digit

class pydocmaker.util._raise_missing(*args, **kwargs)
classmethod __getattr__(name)
pydocmaker.util.bytes_path_exists(b: bytes, encoding: str = 'utf-8') bool

Check if a bytes literal refers to an existing file/directory.

pydocmaker.util.get_inp_context(default_name='main', context: dict = None, **kw)