diff --git a/bindings/python/example_scripts/account_analysis.py b/bindings/python/example_scripts/account_analysis.py index b7e59966a6..bbe6532f71 100644 --- a/bindings/python/example_scripts/account_analysis.py +++ b/bindings/python/example_scripts/account_analysis.py @@ -117,7 +117,7 @@ def next_period_start(start_year, start_month, period_type): def period_end(start_year, start_month, period_type): if period_type not in PERIODS: raise Exception("%s is not a valid period, should be %s" % ( - period_type, str(PERIODS.keys()) ) ) + period_type, str(list(PERIODS.keys())) ) ) end_year, end_month = next_period_start(start_year, start_month, period_type) diff --git a/bindings/python/example_scripts/gnc_convenience.py b/bindings/python/example_scripts/gnc_convenience.py index 808ab38869..2d222379a1 100644 --- a/bindings/python/example_scripts/gnc_convenience.py +++ b/bindings/python/example_scripts/gnc_convenience.py @@ -1,4 +1,4 @@ -#!/usr/bin/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 f015261b0d..f754bc1d24 100644 --- a/bindings/python/example_scripts/latex_invoices.py +++ b/bindings/python/example_scripts/latex_invoices.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- ##@file diff --git a/bindings/python/example_scripts/new_book_with_opening_balances.py b/bindings/python/example_scripts/new_book_with_opening_balances.py index 0ee02c4031..8e21440a05 100644 --- a/bindings/python/example_scripts/new_book_with_opening_balances.py +++ b/bindings/python/example_scripts/new_book_with_opening_balances.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # new_book_with_opening_balances.py -- Replicate the account structure of a # book and apply basis opening balances from the original @@ -334,7 +334,7 @@ def main(): simple_opening_name_used = False for (namespace, mnemonic), (opening_trans, opening_amount) in \ - opening_balance_per_currency.iteritems() : + opening_balance_per_currency.items() : simple_opening_name_used = create_opening_balance_transaction( commodtable, namespace, mnemonic, new_book_root, new_book, diff --git a/bindings/python/example_scripts/priceDB_test.py b/bindings/python/example_scripts/priceDB_test.py index 7af031072a..8ec671500d 100644 --- a/bindings/python/example_scripts/priceDB_test.py +++ b/bindings/python/example_scripts/priceDB_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Test file for price database stuff # To update the price database call # $PATH/gnucash --add-price-quotes $PATHTOFILE diff --git a/bindings/python/example_scripts/price_database_example.py b/bindings/python/example_scripts/price_database_example.py index 13b0d453a0..49c5d28d91 100755 --- a/bindings/python/example_scripts/price_database_example.py +++ b/bindings/python/example_scripts/price_database_example.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Another test file for price database stuff # To update the price database call # $PATH/gnucash --add-price-quotes $PATHTOFILE diff --git a/bindings/python/example_scripts/quotes_historic.py b/bindings/python/example_scripts/quotes_historic.py index c78995abc7..16394b1890 100644 --- a/bindings/python/example_scripts/quotes_historic.py +++ b/bindings/python/example_scripts/quotes_historic.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # quotes_historic.py -- Example Script to read historic quote data into gnucash # diff --git a/bindings/python/example_scripts/rest-api/gnucash_rest.py b/bindings/python/example_scripts/rest-api/gnucash_rest.py index 3ee4ad83ff..d87a15679b 100644 --- a/bindings/python/example_scripts/rest-api/gnucash_rest.py +++ b/bindings/python/example_scripts/rest-api/gnucash_rest.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 ''' @@ -843,7 +843,7 @@ def getSubAccounts(account): flat_accounts = [] - if 'subaccounts' in account.keys(): + if 'subaccounts' in list(account.keys()): for n, subaccount in enumerate(account['subaccounts']): flat_accounts.append(subaccount) flat_accounts = flat_accounts + getSubAccounts(subaccount) @@ -1824,7 +1824,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 diff --git a/bindings/python/example_scripts/simple_book.py b/bindings/python/example_scripts/simple_book.py index 4bde60817e..9a6040b928 100644 --- a/bindings/python/example_scripts/simple_book.py +++ b/bindings/python/example_scripts/simple_book.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 ## @file # @brief Simple example for a book diff --git a/bindings/python/example_scripts/simple_business_create.py b/bindings/python/example_scripts/simple_business_create.py index 75a00228bb..ade0887ad7 100644 --- a/bindings/python/example_scripts/simple_business_create.py +++ b/bindings/python/example_scripts/simple_business_create.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # simple_business_create.py -- Set up a set of books for business feature use # diff --git a/bindings/python/example_scripts/simple_invoice_insert.py b/bindings/python/example_scripts/simple_invoice_insert.py index ad4d7fd0e4..63633d72cb 100644 --- a/bindings/python/example_scripts/simple_invoice_insert.py +++ b/bindings/python/example_scripts/simple_invoice_insert.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # simple_invoice_insert.py -- Add an invoice to a set of books # diff --git a/bindings/python/example_scripts/simple_session.py b/bindings/python/example_scripts/simple_session.py index ee053123c7..3bd219c9c9 100644 --- a/bindings/python/example_scripts/simple_session.py +++ b/bindings/python/example_scripts/simple_session.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 ## @file # @brief Example Script simple session # @ingroup python_bindings_examples @@ -14,7 +14,7 @@ FILE_2 = "/tmp/example_file.xac" session = None try: session = Session(FILE_1) -except GnuCashBackendException, backend_exception: +except GnuCashBackendException as backend_exception: assert( ERR_FILEIO_FILE_NOT_FOUND in backend_exception.errors) @@ -28,7 +28,7 @@ session.destroy() session = Session(FILE_2) try: session_2 = Session(FILE_2) -except GnuCashBackendException, backend_exception: +except GnuCashBackendException as backend_exception: assert( ERR_BACKEND_LOCKED in backend_exception.errors ) session.end() session.destroy() diff --git a/bindings/python/example_scripts/simple_sqlite_create.py b/bindings/python/example_scripts/simple_sqlite_create.py index f3621ec38a..7900c9534d 100644 --- a/bindings/python/example_scripts/simple_sqlite_create.py +++ b/bindings/python/example_scripts/simple_sqlite_create.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 ## @file # @brief Example Script simple sqlite create # @ingroup python_bindings_examples diff --git a/bindings/python/example_scripts/simple_test.py b/bindings/python/example_scripts/simple_test.py index 274164168d..9bc21789e6 100644 --- a/bindings/python/example_scripts/simple_test.py +++ b/bindings/python/example_scripts/simple_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 ## @file # @brief Creates a basic set of accounts and a couple of transactions # @ingroup python_bindings_examples