gnucash maint: Some adjustments, new IPython version
Geert Janssens
gjanssens at code.gnucash.org
Mon Jun 9 13:08:35 EDT 2014
Updated via https://github.com/Gnucash/gnucash/commit/2c955a47 (commit)
from https://github.com/Gnucash/gnucash/commit/2c910ed1 (commit)
commit 2c955a47131e34bb736a2a3e06e61e5e9c64f708
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Thu May 29 23:59:40 2014 +0200
Some adjustments, new IPython version
diff --git a/src/optional/python-bindings/example_scripts/latex_invoices.py b/src/optional/python-bindings/example_scripts/latex_invoices.py
index 622e987..b250684 100644
--- a/src/optional/python-bindings/example_scripts/latex_invoices.py
+++ b/src/optional/python-bindings/example_scripts/latex_invoices.py
@@ -53,7 +53,11 @@ try:
import getopt
import gnucash
import str_methods
- from IPython.Shell import IPShellEmbed
+ from IPython import version_info as IPython_version_info
+ if IPython_version_info[0]>=1:
+ from IPython.terminal.ipapp import TerminalIPythonApp
+ else:
+ from IPython.frontend.terminal.ipapp import TerminalIPythonApp
from gnucash.gnucash_business import Customer, Employee, Vendor, Job, \
Address, Invoice, Entry, TaxTable, TaxTableEntry, GNC_AMT_TYPE_PERCENT, \
GNC_DISC_PRETAX
@@ -120,7 +124,7 @@ def invoice_to_lco(invoice):
add_str=u""
owner = invoice.GetOwner()
if owner.GetName() != "":
- add_str += owner.GetName()+"\n"
+ add_str += owner.GetName().decode("UTF-8")+"\n"
addr = owner.GetAddr()
if addr.GetName() != "":
@@ -191,9 +195,10 @@ def main(argv=None):
prog_name = argv[0]
with_ipshell = False
ignore_lock = False
- no_latex_output = False
+ no_latex_output = True
list_invoices = False
output_file_name = "data.lco"
+ invoice_number = None
try:
opts, args = getopt.getopt(argv[1:], "fhiln:po:", ["help"])
@@ -215,12 +220,10 @@ def main(argv=None):
if opt[0] in ["-n"]:
invoice_number = int(opt[1])
print "using invoice number", invoice_number
+ no_latex_output = False
if opt[0] in ["-o"]:
output_file_name = opt[1]
- print "using outpu file", output_file_name
- if opt[0] in ["-p"]:
- print "no latex output"
- no_latex_output=True
+ print "using output file", output_file_name
if len(args)>1:
print "opts:",opts,"args:",args
raise Usage("Only one input can be accepted !")
@@ -249,9 +252,8 @@ def main(argv=None):
print "-h or --help for this help"
print "-i for ipython shell"
print "-l list all invoices"
- print "-n number use invoice number (no. from previous run -l)"
+ print "-n number use invoice number (no. from previous run with -l)"
print "-o name use name as outputfile. default: data.lco"
- print "-p pretend (=no) latex output"
return retcode
@@ -294,8 +296,9 @@ def main(argv=None):
f.close()
if with_ipshell:
- ipshell= IPShellEmbed()
- ipshell()
+ app = TerminalIPythonApp.instance()
+ app.initialize(argv=[]) # argv=[] instructs IPython to ignore sys.argv
+ app.start()
#session.save()
session.end()
Summary of changes:
.../example_scripts/latex_invoices.py | 25 ++++++++++++----------
1 file changed, 14 insertions(+), 11 deletions(-)
More information about the gnucash-changes
mailing list