Updated the Python driver to mostly match the C++ driver again.
This commit is contained in:
parent
74456d89b5
commit
6e5996e3d0
1 changed files with 113 additions and 92 deletions
53
main.py
53
main.py
|
|
@ -37,12 +37,6 @@ journal = Journal ()
|
|||
|
||||
add_config_option_handlers ()
|
||||
|
||||
output_for_emacs = false
|
||||
def handle_emacs_option (arg):
|
||||
global output_for_emacs
|
||||
output_for_emacs = true
|
||||
add_option_handler ("emacs", "", handle_emacs_option)
|
||||
|
||||
averages = {}
|
||||
compute_monthly_avg = false
|
||||
|
||||
|
|
@ -106,6 +100,10 @@ elif command == "register" or command == "reg" or command == "r":
|
|||
command = "r"
|
||||
elif command == "print" or command == "p":
|
||||
command = "p"
|
||||
elif command == "output":
|
||||
command = "w"
|
||||
elif command == "emacs":
|
||||
command = "x"
|
||||
elif command == "entry":
|
||||
command = "e"
|
||||
elif command == "equity":
|
||||
|
|
@ -125,20 +123,27 @@ else:
|
|||
# module was built with such support (which requires the xmlparse C
|
||||
# library).
|
||||
|
||||
text_parser = TextualParser ()
|
||||
bin_parser = BinaryParser ()
|
||||
qif_parser = QifParser ()
|
||||
gnucash_parser = None
|
||||
try:
|
||||
gnucash_parser = GnucashParser ()
|
||||
except:
|
||||
pass
|
||||
xml_parser = None
|
||||
try: xml_parser = GnucashParser ()
|
||||
except: pass
|
||||
try: gnucash_parser = GnucashParser ()
|
||||
except: pass
|
||||
try: ofx_parser = OfxParser ()
|
||||
except: pass
|
||||
qif_parser = QifParser ()
|
||||
text_parser = TextualParser ()
|
||||
|
||||
register_parser (text_parser)
|
||||
register_parser (bin_parser)
|
||||
if xml_parser:
|
||||
register_parser (xml_parser)
|
||||
if gnucash_parser:
|
||||
register_parser (gnucash_parser)
|
||||
if ofx_parser:
|
||||
register_parser (ofx_parser)
|
||||
register_parser (qif_parser)
|
||||
register_parser (text_parser)
|
||||
|
||||
# Parse all entries from the user specified locations (found in
|
||||
# 'config') into the journal object we created. The two parsers given
|
||||
|
|
@ -194,6 +199,8 @@ elif command == "P":
|
|||
format = config.prices_format
|
||||
elif command == "D":
|
||||
format = config.pricesdb_format
|
||||
elif command == "w":
|
||||
format = config.write_xact_format
|
||||
else:
|
||||
format = config.print_format
|
||||
|
||||
|
|
@ -364,17 +371,32 @@ if command == "b" or command == "E":
|
|||
handler = SetAccountValue ()
|
||||
elif command == "p" or command == "e":
|
||||
handler = FormatEntries (format)
|
||||
elif output_for_emacs:
|
||||
elif command == "x":
|
||||
import emacs
|
||||
handler = emacs.EmacsFormatTransactions ()
|
||||
else:
|
||||
handler = FormatTransactions (format)
|
||||
|
||||
if command == "w":
|
||||
if config.output_file:
|
||||
out = open (config.output_file, "w")
|
||||
else:
|
||||
out = sys.stdout
|
||||
|
||||
write_textual_journal(journal, args, handler, out);
|
||||
|
||||
if config.output_file:
|
||||
out.close ()
|
||||
else:
|
||||
# Chain transaction filters on top of the base handler. Most of these
|
||||
# filters customize the output for reporting. None of this is done
|
||||
# for balance or equity reports, which don't need it.
|
||||
|
||||
if not (command == "b" or command == "E"):
|
||||
if config.head_entries or config.tail_entries:
|
||||
handler = TruncateEntries (handler, config.head_entries,
|
||||
config.tail_entries)
|
||||
|
||||
if config.display_predicate:
|
||||
handler = FilterTransactions (handler, config.display_predicate)
|
||||
|
||||
|
|
@ -473,8 +495,7 @@ elif command == "E":
|
|||
# If it were important to clean things up, we would have to clear out
|
||||
# the accumulated xdata at this point:
|
||||
|
||||
#clear_transactions_xdata ()
|
||||
#clear_accounts_xdata ()
|
||||
#clear_all_xdata ()
|
||||
|
||||
# If the cache is being used, and is dirty, update it now.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue