kibitzr.transformer package

Submodules

kibitzr.transformer.factory module

Built-in transforms

class kibitzr.transformer.factory.TransformPipeline(conf)[source]

Bases: object

Create transformation pipeline from check conf. Class instances are callable (executing run_pipeline)

REGISTRY = {'bash': <function bake_parametrized.<locals>.transform_factory>, 'changes': <function changes_transform_factory>, 'css': functools.partial(<bound method SoupOps.factory of <class 'kibitzr.transformer.html.SoupOps'>>, 'css'), 'css-all': functools.partial(<bound method SoupOps.factory of <class 'kibitzr.transformer.html.SoupOps'>>, 'css-all'), 'jinja': <class 'kibitzr.transformer.jinja_transform.JinjaTransform'>, 'jq': <function bake_parametrized.<locals>.transform_factory>, 'json': <function wrap_dummy.<locals>.transform_factory>, 'python': <function bake_parametrized.<locals>.transform_factory>, 'shell': <function bake_parametrized.<locals>.transform_factory>, 'tag': functools.partial(<bound method SoupOps.factory of <class 'kibitzr.transformer.html.SoupOps'>>, 'tag'), 'text': functools.partial(<bound method SoupOps.factory of <class 'kibitzr.transformer.html.SoupOps'>>, 'text'), 'xpath': <function bake_parametrized.<locals>.transform_factory>, 'xpath-all': <function bake_parametrized.<locals>.transform_factory>}
create_transform(rule)[source]

Create single transform from rule. Rule can be string, or {key: value} pair

on_error(content)[source]

In case of error, conf[‘error’] is checked for policy name. It can be ‘ignore’, or ‘notify’ (default). Ignore policy replaces content with None, Notify policy passes content through.

run_pipeline(ok, content)[source]
kibitzr.transformer.factory.load_transforms()[source]
kibitzr.transformer.factory.transform_factory

alias of TransformPipeline

kibitzr.transformer.html module

class kibitzr.transformer.html.SoupOps(selector=None, select_all=False)[source]

Bases: object

SHORTCUTS = {'css': <function SoupOps.css_selector>, 'tag': <function SoupOps.tag_selector>, 'text': <staticmethod object>}
css_selector(html)[source]
static extract_text(html)[source]
classmethod factory(key, value, conf)[source]
tag_selector(html)[source]
kibitzr.transformer.html.bake_html(key)[source]
kibitzr.transformer.html.deep_recursion()[source]
kibitzr.transformer.html.register()[source]

Return dictionary of transform factories

kibitzr.transformer.html.soup(html)[source]

kibitzr.transformer.jinja_transform module

class kibitzr.transformer.jinja_transform.JinjaTransform(code, conf)[source]

Bases: object

context(content)[source]
render(content, context=None)[source]
class kibitzr.transformer.jinja_transform.LazyHTML(content)[source]

Bases: object

css(selector)[source]
property soup
class kibitzr.transformer.jinja_transform.LazyJSON(content)[source]

Bases: object

property json
class kibitzr.transformer.jinja_transform.LazyXML(content)[source]

Bases: object

property root
xpath(selector)[source]
kibitzr.transformer.jinja_transform.dollars_filter(number)[source]
kibitzr.transformer.jinja_transform.float_filter(text)[source]
kibitzr.transformer.jinja_transform.ignore_cast_error(func)[source]
kibitzr.transformer.jinja_transform.int_filter(text)[source]
kibitzr.transformer.jinja_transform.register()[source]
kibitzr.transformer.jinja_transform.text_filter(html)[source]

kibitzr.transformer.json_transforms module

kibitzr.transformer.json_transforms.pretty_json(text)[source]
kibitzr.transformer.json_transforms.register()[source]
kibitzr.transformer.json_transforms.run_jq(query, text)[source]

kibitzr.transformer.plain_text module

kibitzr.transformer.plain_text.bash_transform(code, content)[source]
kibitzr.transformer.plain_text.changes_transform_factory(value, conf)[source]
kibitzr.transformer.plain_text.python_transform(code, content, conf)[source]
kibitzr.transformer.plain_text.register()[source]

kibitzr.transformer.utils module

kibitzr.transformer.utils.bake_parametrized(transform_func, pass_conf=False, **kwargs)[source]
kibitzr.transformer.utils.wrap_dummy(transform_func)[source]

Module contents