gnucash maint: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Tue Oct 16 12:40:43 EDT 2018
Updated via https://github.com/Gnucash/gnucash/commit/d9ed8475 (commit)
via https://github.com/Gnucash/gnucash/commit/64a28b52 (commit)
via https://github.com/Gnucash/gnucash/commit/97916c66 (commit)
via https://github.com/Gnucash/gnucash/commit/34fa18f0 (commit)
from https://github.com/Gnucash/gnucash/commit/9f5c60de (commit)
commit d9ed84759589674b30454cc14cf9241169cd0b81
Merge: 9f5c60d 64a28b5
Author: John Ralls <jralls at ceridwen.us>
Date: Tue Oct 16 09:37:25 2018 -0700
Merge Christoph Holterman's 'PR-python2to3fixes' into maint.
diff --cc bindings/python/example_scripts/change_tax_code.py
index 56ad767,85255cf..df7fe3d
--- a/bindings/python/example_scripts/change_tax_code.py
+++ b/bindings/python/example_scripts/change_tax_code.py
@@@ -1,7 -1,7 +1,7 @@@
- #!/usr/bin/env python
+ #!/usr/bin/env python3
## @file
-# @brief Output all the credits and debits on an account
+# @brief Recurse over all accounts in a book and marks the first one having target_account_code as tax related
# @ingroup python_bindings_examples
from gnucash import Session, Account
commit 64a28b526370766f1e090a7711372bd1ac60e6e0
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Sat Sep 22 18:12:11 2018 +0200
xrange deprecated in python3, change to range
thanks to Sumit Bhardwaj for the hint
diff --git a/bindings/python/example_scripts/account_analysis.py b/bindings/python/example_scripts/account_analysis.py
index 07dbf4e..b7e5996 100644
--- a/bindings/python/example_scripts/account_analysis.py
+++ b/bindings/python/example_scripts/account_analysis.py
@@ -129,7 +129,7 @@ def period_end(start_year, start_month, period_type):
def generate_period_boundaries(start_year, start_month, period_type, periods):
- for i in xrange(periods):
+ for i in range(periods):
yield ( date(start_year, start_month, 1),
period_end(start_year, start_month, period_type) )
start_year, start_month = next_period_start(start_year, start_month,
diff --git a/bindings/python/example_scripts/simple_invoice_insert.py b/bindings/python/example_scripts/simple_invoice_insert.py
index cab1769..ad4d7fd 100644
--- a/bindings/python/example_scripts/simple_invoice_insert.py
+++ b/bindings/python/example_scripts/simple_invoice_insert.py
@@ -22,7 +22,7 @@
# @author Mark Jenkins, ParIT Worker Co-operative <mark at parit.ca>
# Opens a GnuCash book file and adds an invoice to it for a particular
-# customer (by ID) with a specific ID and value
+# customer (by ID) with a specific ID and value
# Optionally also adds a payment for the invoice as well
#
# The account tree and tax tables are assumed to be the same as the ones
@@ -67,7 +67,7 @@ def gnc_numeric_from_decimal(decimal_value):
numerator_place_value = 1
# add each digit to the final value multiplied by the place value
# from least significant to most sigificant
- for i in xrange(len(digits)-1,-1,-1):
+ for i in range(len(digits)-1,-1,-1):
numerator += digits[i] * numerator_place_value
numerator_place_value *= TEN
commit 97916c6682d8675945c1a98e3ee7b6b0924d8eb1
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Fri Sep 21 09:28:41 2018 +0200
whitespace fixes
diff --git a/bindings/python/example_scripts/account_analysis.py b/bindings/python/example_scripts/account_analysis.py
index 0326941..07dbf4e 100644
--- a/bindings/python/example_scripts/account_analysis.py
+++ b/bindings/python/example_scripts/account_analysis.py
@@ -45,7 +45,7 @@ from gnucash import Session, GncNumeric, Split
# That will do an analysis on the account 'Assets:Test Account' from
# gnucash_file.xac, all of the debits and all of the credits will be shown
# and summed on for 12 monthly periods starting from January (1st month) 2010
-#
+#
# if you just want to see the credit and debit sums for each period, use
# the debits-noshow and credits-noshow argument
#
@@ -92,7 +92,7 @@ def gnc_numeric_to_python_Decimal(numeric):
exponent = int(log10(denominator))
assert( (10 ** exponent) == denominator )
return Decimal( (sign, digit_tuple, -exponent) )
-
+
def next_period_start(start_year, start_month, period_type):
# add numbers of months for the period length
@@ -112,7 +112,7 @@ def next_period_start(start_year, start_month, period_type):
end_month = ( (end_month-1) % NUM_MONTHS ) + 1
return end_year, end_month
-
+
def period_end(start_year, start_month, period_type):
if period_type not in PERIODS:
@@ -126,7 +126,7 @@ def period_end(start_year, start_month, period_type):
# so we get a period end like
# 2010-03-31 for period starting 2010-01 instead of 2010-04-01
return date(end_year, end_month, 1) - ONE_DAY
-
+
def generate_period_boundaries(start_year, start_month, period_type, periods):
for i in xrange(periods):
@@ -192,7 +192,7 @@ def main():
]
# a copy of the above list with just the period start dates
period_starts = [e[0] for e in period_list ]
-
+
# insert and add all splits in the periods of interest
for split in account_of_interest.GetSplitList():
trans = split.parent
@@ -201,13 +201,13 @@ def main():
# use binary search to find the period that starts before or on
# the transaction date
period_index = bisect_right( period_starts, trans_date ) - 1
-
+
# ignore transactions with a date before the matching period start
# (after subtracting 1 above start_index would be -1)
# and after the last period_end
if period_index >= 0 and \
trans_date <= period_list[len(period_list)-1][1]:
-
+
# get the period bucket appropriate for the split in question
period = period_list[period_index]
@@ -220,7 +220,7 @@ def main():
# and the filtered results from the above if provide all the
# protection we need
assert( trans_date>= period[0] and trans_date <= period[1] )
-
+
split_amount = gnc_numeric_to_python_Decimal(split.GetAmount())
# if the amount is negative, this is a credit
@@ -235,20 +235,20 @@ def main():
#
# if we wanted to be really cool we'd keep the transactions
period[2+debit_credit_offset].append( (trans, split) )
-
+
# add the debit or credit to the sum, using the above offset
# to get in the right bucket
period[4+debit_credit_offset] += split_amount
csv_writer = csv.writer(stdout)
csv_writer.writerow( ('period start', 'period end', 'debits', 'credits') )
-
+
def generate_detail_rows(values):
return (
('', '', '', '', trans.GetDescription(),
gnc_numeric_to_python_Decimal(split.GetAmount()))
for trans, split in values )
-
+
for start_date, end_date, debits, credits, debit_sum, credit_sum in \
period_list:
diff --git a/bindings/python/example_scripts/change_tax_code.py b/bindings/python/example_scripts/change_tax_code.py
index 56aab31..85255cf 100644
--- a/bindings/python/example_scripts/change_tax_code.py
+++ b/bindings/python/example_scripts/change_tax_code.py
@@ -24,7 +24,7 @@ def mark_account_with_code_as_tax_related(account, target_code):
if mark_account_with_code_as_tax_related(child, target_code):
return True
return False
-
+
# Change this path to your own
gnucash_session = Session("/home/mark/python-bindings-help/test.xac")
diff --git a/bindings/python/example_scripts/test_imbalance_transaction.py b/bindings/python/example_scripts/test_imbalance_transaction.py
index 08c7cb7..aa5eef0 100644
--- a/bindings/python/example_scripts/test_imbalance_transaction.py
+++ b/bindings/python/example_scripts/test_imbalance_transaction.py
@@ -41,7 +41,7 @@ from gnucash import Session, Transaction, Split, Account, GncNumeric, \
# You should try it out with a gnucash file with tranding accounts enabled
# and trading accounts disabled
-if len(argv) < 2:
+if len(argv) < 2:
print('not enough parameters')
print('usage: test_imbalance_transaction.py {book_url}')
print('examples:')
commit 34fa18f04eebef4fe0ca8e371d3974448fc5424e
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Fri Sep 21 09:27:17 2018 +0200
additional fixes for python3
diff --git a/bindings/python/example_scripts/account_analysis.py b/bindings/python/example_scripts/account_analysis.py
index 87e1dfe..0326941 100644
--- a/bindings/python/example_scripts/account_analysis.py
+++ b/bindings/python/example_scripts/account_analysis.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# account_analysis.py -- Output all the credits and debits on an account
#
diff --git a/bindings/python/example_scripts/change_tax_code.py b/bindings/python/example_scripts/change_tax_code.py
index 628b2f3..56aab31 100644
--- a/bindings/python/example_scripts/change_tax_code.py
+++ b/bindings/python/example_scripts/change_tax_code.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
## @file
# @brief Output all the credits and debits on an account
diff --git a/bindings/python/example_scripts/gncinvoicefkt.py b/bindings/python/example_scripts/gncinvoicefkt.py
index ef778b4..8caaa57 100644
--- a/bindings/python/example_scripts/gncinvoicefkt.py
+++ b/bindings/python/example_scripts/gncinvoicefkt.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
##@file
diff --git a/bindings/python/example_scripts/latex_invoices.py b/bindings/python/example_scripts/latex_invoices.py
index 4c6c1d4..76d1c51 100644
--- a/bindings/python/example_scripts/latex_invoices.py
+++ b/bindings/python/example_scripts/latex_invoices.py
@@ -179,7 +179,7 @@ def main(argv=None):
try:
opts, args = getopt.getopt(argv[1:], "fhiln:po:", ["help"])
- except getopt.error, msg:
+ except getopt.error as msg:
raise Usage(msg)
for opt in opts:
@@ -207,12 +207,12 @@ def main(argv=None):
if len(args)==0:
raise Usage("No input given !")
input_url = args[0]
- except Usage, err:
+ except Usage as err:
if err.msg == "Help:":
retcode=0
else:
- print(>>sys.stderr, "Error:",err.msg)
- print(>>sys.stderr, "for help use --help")
+ print("Error:", err.msg, file=sys.stderr)
+ print("for help use --help", file=sys.stderr)
retcode=2
print("Generate a LaTeX invoice or print out all invoices.")
diff --git a/bindings/python/example_scripts/test_imbalance_transaction.py b/bindings/python/example_scripts/test_imbalance_transaction.py
index d220728..08c7cb7 100644
--- a/bindings/python/example_scripts/test_imbalance_transaction.py
+++ b/bindings/python/example_scripts/test_imbalance_transaction.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# test_imbalance_transaction.py -- Test the transaction imbalace viewing
# mechanisms
Summary of changes:
.../python/example_scripts/account_analysis.py | 26 +++++++++++-----------
bindings/python/example_scripts/change_tax_code.py | 4 ++--
bindings/python/example_scripts/gncinvoicefkt.py | 2 +-
bindings/python/example_scripts/latex_invoices.py | 8 +++----
.../example_scripts/simple_invoice_insert.py | 4 ++--
.../example_scripts/test_imbalance_transaction.py | 4 ++--
6 files changed, 24 insertions(+), 24 deletions(-)
More information about the gnucash-changes
mailing list