Exemple #1
0
def load_file():
    for filepath in app.config['BEANCOUNT_FILES']:
        api = BeancountReportAPI(filepath)
        slug = slugify(api.options['title'])
        if not slug:
            slug = slugify(filepath)
        app.config['APIS'][slug] = api
    app.config['FILE_SLUGS'] = list(app.config['APIS'].keys())
Exemple #2
0
def load_file():
    for filepath in app.config['BEANCOUNT_FILES']:
        api = BeancountReportAPI(filepath)
        slug = slugify(api.options['title'])
        if not slug:
            slug = slugify(filepath)
        app.config['APIS'][slug] = api
    app.config['FILE_SLUGS'] = list(app.config['APIS'].keys())
Exemple #3
0
def load_file():
    """Load Beancount files. """
    for filepath in app.config['BEANCOUNT_FILES']:
        ledger = FavaLedger(filepath)
        slug = slugify(ledger.options['title'])
        if not slug:
            slug = slugify(filepath)
        app.config['LEDGERS'][slug] = ledger
    app.config['FILE_SLUGS'] = list(app.config['LEDGERS'].keys())
Exemple #4
0
def _load_file():
    """Load Beancount files.

    This is run automatically on the first request.
    """
    app.config["LEDGERS"] = {}
    for filepath in app.config["BEANCOUNT_FILES"]:
        ledger = FavaLedger(filepath)
        slug = slugify(ledger.options["title"])
        if not slug:
            slug = slugify(filepath)
        app.config["LEDGERS"][slug] = ledger
    app.config["FILE_SLUGS"] = list(app.config["LEDGERS"].keys())
Exemple #5
0
def _load_file():
    """Load Beancount files.

    This is run automatically on the first request.
    """
    app.config['LEDGERS'] = {}
    for filepath in app.config['BEANCOUNT_FILES']:
        ledger = FavaLedger(filepath)
        slug = slugify(ledger.options['title'])
        if not slug:
            slug = slugify(filepath)
        app.config['LEDGERS'][slug] = ledger
    app.config['FILE_SLUGS'] = list(app.config['LEDGERS'].keys())
Exemple #6
0
def test_slugify():
    assert slugify("Example Beancount File") == "example-beancount-file"
    assert slugify("    Example Beancount File  ") == "example-beancount-file"
    assert slugify("test") == "test"
    assert slugify("烫烫烫") == "烫烫烫"
    assert slugify("nonun烫icode 烫烫") == "nonun烫icode-烫烫"
    assert slugify("%✓") == ""
    assert slugify("söße") == "söße"
    assert slugify("ASDF") == "asdf"
    assert slugify("ASDF test test") == "asdf-test-test"
Exemple #7
0
def test_slugify():
    assert slugify('Example Beancount File') == 'example-beancount-file'
    assert slugify('    Example Beancount File  ') == 'example-beancount-file'
    assert slugify('test') == 'test'
    assert slugify('烫烫烫') == '烫烫烫'
    assert slugify('nonun烫icode 烫烫') == 'nonun烫icode-烫烫'
    assert slugify('%✓') == ''
    assert slugify('söße') == 'söße'
    assert slugify('ASDF') == 'asdf'
    assert slugify('ASDF test test') == 'asdf-test-test'
Exemple #8
0
def test_slugify():
    assert slugify('Example Beancount File') == 'example-beancount-file'
    assert slugify('    Example Beancount File  ') == 'example-beancount-file'
    assert slugify('test') == 'test'
    assert slugify('烫烫烫') == '烫烫烫'
    assert slugify('nonun烫icode 烫烫') == 'nonun烫icode-烫烫'
    assert slugify('%✓') == ''
    assert slugify('söße') == 'söße'
    assert slugify('ASDF') == 'asdf'
    assert slugify('ASDF test test') == 'asdf-test-test'
Exemple #9
0
def _load_file():
    """Load Beancount files.

    This is run automatically on the first request.
    """
    app.config['LEDGERS'] = {}
    for filepath in app.config['BEANCOUNT_FILES']:
        ledger = FavaLedger(filepath)
        slug = slugify(ledger.options['title'])
        if not slug:
            slug = slugify(filepath)
        app.config['LEDGERS'][slug] = ledger
    # actually contains ledger instances, wtf is slug?
    app.config['FILE_SLUGS'] = list(app.config['LEDGERS'].keys())
Exemple #10
0
def ledger_slug(ledger: FavaLedger) -> str:
    """Generate URL slug for a ledger."""
    title_slug = slugify(ledger.options["title"])
    return title_slug or slugify(ledger.beancount_file_path)