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())
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())
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())
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())
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"
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'
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())
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)