How to use the buku.to_temp_file_content function in buku

To help you get started, we’ve selected a few buku 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 jarun / Buku / tests / test_buku.py View on Github external
desc_text = '\n'
    elif desc == '':
        desc_text = '-'
    else:
        desc_text = desc
    if title_in is None:
        title_text = ''
    elif title_in == '':
        title_text = '-'
    else:
        title_text = title_in
    if tags_in is None:
        with pytest.raises(AttributeError):
            res = buku.to_temp_file_content(url, title_in, tags_in, desc)
        return
    res = buku.to_temp_file_content(url, title_in, tags_in, desc)
    lines = """# Lines beginning with "#" will be stripped.
# Add URL in next line (single line).{}
# Add TITLE in next line (single line). Leave blank to web fetch, "-" for no title.{}
# Add comma-separated TAGS in next line (single line).{}
# Add COMMENTS in next line(s). Leave blank to web fetch, "-" for no comments.{}""".format(
        ''.join(['\n', url]) if url is not None else '',
        ''.join(['\n', title_text]),
        ''.join(['\n', ','.join([x for x in tags_in.split(',') if x])]) if tags_in else '\n',
        ''.join(['\n', desc_text])
    )
    assert res == lines
github jarun / Buku / tests / test_buku.py View on Github external
import buku
    if desc is None:
        desc_text = '\n'
    elif desc == '':
        desc_text = '-'
    else:
        desc_text = desc
    if title_in is None:
        title_text = ''
    elif title_in == '':
        title_text = '-'
    else:
        title_text = title_in
    if tags_in is None:
        with pytest.raises(AttributeError):
            res = buku.to_temp_file_content(url, title_in, tags_in, desc)
        return
    res = buku.to_temp_file_content(url, title_in, tags_in, desc)
    lines = """# Lines beginning with "#" will be stripped.
# Add URL in next line (single line).{}
# Add TITLE in next line (single line). Leave blank to web fetch, "-" for no title.{}
# Add comma-separated TAGS in next line (single line).{}
# Add COMMENTS in next line(s). Leave blank to web fetch, "-" for no comments.{}""".format(
        ''.join(['\n', url]) if url is not None else '',
        ''.join(['\n', title_text]),
        ''.join(['\n', ','.join([x for x in tags_in.split(',') if x])]) if tags_in else '\n',
        ''.join(['\n', desc_text])
    )
    assert res == lines