How to use the kibitzr.storage.PageHistory function in kibitzr

To help you get started, we’ve selected a few kibitzr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kibitzr / kibitzr / tests / unit / transforms / test_changes.py View on Github external
def history(style=None):
    storage_dir = tempfile.mkdtemp()
    page_history = PageHistory(
        conf={'name': 'test', 'url': 'web'},
        storage_dir=storage_dir,
        style=style,
    )
    try:
        yield page_history
    finally:
        shutil.rmtree(storage_dir, ignore_errors=True)
github kibitzr / kibitzr / kibitzr / storage.py View on Github external
def report_changes(conf, content):
    return PageHistory(conf).report_changes(content)
github kibitzr / kibitzr / kibitzr / transformer / plain_text.py View on Github external
def changes_transform_factory(value, conf):
    style = value.lower() if value else None
    return PageHistory(conf, style=style).report_changes
github kibitzr / kibitzr / kibitzr / storage.py View on Github external
def clean():
        """Remove storage dir (delete all git repos)"""
        shutil.rmtree(PageHistory.STORAGE_DIR)
github kibitzr / kibitzr / kibitzr / transformer.py View on Github external
name, value = next(iter(rule.items()))
    except AttributeError:
        name, value = rule, None
    if name == 'css':
        return functools.partial(css_selector, value)
    if name == 'css-all':
        return functools.partial(css_selector, value, select_all=True)
    elif name == 'xpath':
        return functools.partial(xpath_selector, value)
    elif name == 'tag':
        return functools.partial(tag_selector, value)
    elif name == 'text':
        return extract_text
    elif name == 'changes':
        style = value.lower() if value else None
        return PageHistory(conf, style=style).report_changes
    elif name == 'json':
        return pretty_json
    elif name == 'jq':
        return functools.partial(run_jq, value)
    elif name == 'sort':
        return sort_lines
    elif name == 'cut':
        return functools.partial(cut_lines, value)
    elif name == 'python':
        return functools.partial(python_transform, conf=conf, code=value)
    elif name == 'bash':
        return functools.partial(bash_transform, code=value)
    else:
        raise RuntimeError(
            "Unknown transformer: %r" % (name,)
        )
github kibitzr / kibitzr / kibitzr / cli.py View on Github external
def clean():
    """Clean change history"""
    from kibitzr.storage import PageHistory
    PageHistory.clean()