mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-07 21:29:13 +00:00
Only extract transactions from Beancount
- Earlier was extracting all entries starting with dates but the other type of entries like account open/close, asserts etc aren't useful for querying
This commit is contained in:
@@ -113,7 +113,7 @@ def extract_beancount_entries(beancount_files):
|
|||||||
"Extract entries from specified Beancount files"
|
"Extract entries from specified Beancount files"
|
||||||
|
|
||||||
# Initialize Regex for extracting Beancount Entries
|
# Initialize Regex for extracting Beancount Entries
|
||||||
date_regex = r'^\n?\d{4}-\d{2}-\d{2}'
|
transaction_regex = r'^\n?\d{4}-\d{2}-\d{2} [\*|\!] '
|
||||||
empty_newline = f'^[{empty_escape_sequences}]*$'
|
empty_newline = f'^[{empty_escape_sequences}]*$'
|
||||||
|
|
||||||
entries = []
|
entries = []
|
||||||
@@ -123,7 +123,7 @@ def extract_beancount_entries(beancount_files):
|
|||||||
entries.extend([entry.strip(empty_escape_sequences)
|
entries.extend([entry.strip(empty_escape_sequences)
|
||||||
for entry
|
for entry
|
||||||
in re.split(empty_newline, ledger_content, flags=re.MULTILINE)
|
in re.split(empty_newline, ledger_content, flags=re.MULTILINE)
|
||||||
if re.match(date_regex, entry)])
|
if re.match(transaction_regex, entry)])
|
||||||
|
|
||||||
return entries
|
return entries
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user