|
| 1 | +import csv |
| 2 | +import datetime |
| 3 | +import enum |
| 4 | +from collections.abc import Sequence |
| 5 | +from typing import Any |
| 6 | +from typing import NamedTuple |
| 7 | +from typing import TypeAlias |
| 8 | + |
| 9 | +import beancount.core.amount |
| 10 | +import beangulp |
| 11 | +from beancount.core import data |
| 12 | + |
| 13 | +from fava.beans.abc import Directive |
| 14 | + |
| 15 | +Row: TypeAlias = NamedTuple |
| 16 | + |
| 17 | +class Order(enum.Enum): |
| 18 | + ASCENDING = ... |
| 19 | + DESCENDING = ... |
| 20 | + |
| 21 | +class Column: |
| 22 | + name: str |
| 23 | + def __init__(self, name: str) -> None: ... |
| 24 | + def parse(self, value: str) -> Any: ... |
| 25 | + |
| 26 | +class Date(Column): |
| 27 | + format: str |
| 28 | + def __init__(self, name: str, frmt: str) -> None: ... |
| 29 | + def parse(self, value: str) -> datetime.date: ... |
| 30 | + |
| 31 | +class Amount(Column): |
| 32 | + subs: dict[str, str] |
| 33 | + def __init__( |
| 34 | + self, name: str, subs: dict[str, str] | None = None |
| 35 | + ) -> None: ... |
| 36 | + def parse(self, value: str) -> beancount.core.amount.Amount: ... |
| 37 | + |
| 38 | +class Columns(Column): |
| 39 | + columns: list[str] |
| 40 | + sep: str |
| 41 | + def __init__(self, *columns: str, sep: str = " ") -> None: ... |
| 42 | + def parse(self, value: str) -> str: ... |
| 43 | + |
| 44 | +class CreditOrDebit(Column): |
| 45 | + credit_name: str |
| 46 | + debit_name: str |
| 47 | + def __init__(self, credit_name: str, debit_name: str) -> None: ... |
| 48 | + def parse(self, value: str) -> beancount.core.amount.Amount: ... |
| 49 | + |
| 50 | +class CSVMeta(type): ... |
| 51 | + |
| 52 | +class CSVReader: |
| 53 | + encoding: str |
| 54 | + skiplines: int |
| 55 | + names: bool |
| 56 | + dialect: str | csv.Dialect |
| 57 | + comments: str |
| 58 | + order: Order | None |
| 59 | + |
| 60 | + def read(self, filepath: str) -> list[Row]: ... |
| 61 | + |
| 62 | +class Importer(beangulp.Importer, CSVReader): |
| 63 | + def __init__( |
| 64 | + self, account: str, currency: str, flag: str = "*" |
| 65 | + ) -> None: ... |
| 66 | + def account(self, filepath: str) -> str: ... |
| 67 | + def date(self, filepath: str) -> datetime.date: ... |
| 68 | + def extract( |
| 69 | + self, filepath: str, existing: Sequence[Directive] |
| 70 | + ) -> list[Directive]: ... |
| 71 | + def finalize( |
| 72 | + self, txn: data.Transaction, row: Row |
| 73 | + ) -> data.Transaction | None: ... |
| 74 | + def identify(self, filepath: str) -> bool: ... |
| 75 | + def metadata(self, filepath: str, lineno: int, row: Row) -> data.Meta: ... |
0 commit comments