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:
Debanjum Singh Solanky
2022-07-19 19:50:58 +04:00
parent 732b2d287f
commit e66cd5bf59

View File

@@ -113,7 +113,7 @@ def extract_beancount_entries(beancount_files):
"Extract entries from specified Beancount files"
# 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}]*$'
entries = []
@@ -123,7 +123,7 @@ def extract_beancount_entries(beancount_files):
entries.extend([entry.strip(empty_escape_sequences)
for entry
in re.split(empty_newline, ledger_content, flags=re.MULTILINE)
if re.match(date_regex, entry)])
if re.match(transaction_regex, entry)])
return entries