Python 3 compatibility syntax error fixes (#10519)

* Use Python 3 style print function

* Use 'Exception as e' instead of 'Exception, e'

* Unpack tuple arguments explicitly in instead of relying on auto unpacking

* Use consistent indentation

* Use 0 if stock_frozen_upto_days is None
This commit is contained in:
Aditya Hase
2017-08-28 18:17:36 +05:30
committed by Rushabh Mehta
parent 7ed4bfe7ee
commit 6ccb6562f1
43 changed files with 141 additions and 138 deletions

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
from __future__ import print_function, unicode_literals
import frappe
from frappe.utils import flt
@@ -37,7 +37,7 @@ def execute():
if stock_bal and account_bal and abs(flt(stock_bal[0][0]) - flt(account_bal[0][0])) > 0.1:
try:
print voucher_type, voucher_no, stock_bal[0][0], account_bal[0][0]
print(voucher_type, voucher_no, stock_bal[0][0], account_bal[0][0])
frappe.db.sql("""delete from `tabGL Entry`
where voucher_type=%s and voucher_no=%s""", (voucher_type, voucher_no))
@@ -45,10 +45,10 @@ def execute():
voucher = frappe.get_doc(voucher_type, voucher_no)
voucher.make_gl_entries(repost_future_gle=False)
frappe.db.commit()
except Exception, e:
print frappe.get_traceback()
except Exception as e:
print(frappe.get_traceback())
rejected.append([voucher_type, voucher_no])
frappe.db.rollback()
print "Failed to repost: "
print rejected
print("Failed to repost: ")
print(rejected)

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
from __future__ import print_function, unicode_literals
import frappe
def execute():
@@ -109,7 +109,7 @@ def delete_individual_party_account():
and exists(select gle.name from `tabGL Entry` gle where gle.account = tabAccount.name)""")
if accounts_not_deleted:
print "Accounts not deleted: " + "\n".join(accounts_not_deleted)
print("Accounts not deleted: " + "\n".join(accounts_not_deleted))
def remove_customer_supplier_account_report():

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
from __future__ import print_function, unicode_literals
import frappe
from erpnext.stock.stock_ledger import NegativeStockError
@@ -28,7 +28,7 @@ def execute():
frappe.local.stockledger_exceptions = None
frappe.db.rollback()
print "Failed to repost: ", failed_list
print("Failed to repost: ", failed_list)

View File

@@ -1,13 +1,13 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
from __future__ import print_function, unicode_literals
import frappe
def execute():
country = frappe.db.get_single_value("Global Defaults", "country")
if not country:
print "Country not specified in Global Defaults"
print("Country not specified in Global Defaults")
return
for company in frappe.db.sql_list("""select name from `tabCompany`