chore: remove past module dependencies
diff --git a/erpnext/accounts/doctype/tax_rule/tax_rule.py b/erpnext/accounts/doctype/tax_rule/tax_rule.py
index e1d630d..b0d6983 100644
--- a/erpnext/accounts/doctype/tax_rule/tax_rule.py
+++ b/erpnext/accounts/doctype/tax_rule/tax_rule.py
@@ -10,7 +10,6 @@
from frappe.model.document import Document
from frappe.utils import cint, cstr
from frappe.utils.nestedset import get_root_of
-from past.builtins import cmp
from six import iteritems
from erpnext.setup.doctype.customer_group.customer_group import get_parent_customer_groups
@@ -170,6 +169,10 @@
for key in args:
if rule.get(key): rule.no_of_keys_matched += 1
+ def cmp(a, b):
+ # refernce: https://docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons
+ return int(a > b) - int(a < b)
+
rule = sorted(tax_rule,
key = functools.cmp_to_key(lambda b, a:
cmp(a.no_of_keys_matched, b.no_of_keys_matched) or
diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py
index 2729433..37ff103 100644
--- a/erpnext/accounts/report/financial_statements.py
+++ b/erpnext/accounts/report/financial_statements.py
@@ -10,7 +10,6 @@
import frappe
from frappe import _
from frappe.utils import add_days, add_months, cint, cstr, flt, formatdate, get_first_day, getdate
-from past.builtins import cmp
from six import itervalues
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
@@ -343,7 +342,7 @@
def compare_accounts(a, b):
if re.split(r'\W+', a[key])[0].isdigit():
# if chart of accounts is numbered, then sort by number
- return cmp(a[key], b[key])
+ return int(a[key] > b[key]) - int(a[key] < b[key])
elif is_root:
if a.report_type != b.report_type and a.report_type == "Balance Sheet":
return -1
@@ -355,7 +354,7 @@
return -1
else:
# sort by key (number) or name
- return cmp(a[key], b[key])
+ return int(a[key] > b[key]) - int(a[key] < b[key])
return 1
accounts.sort(key = functools.cmp_to_key(compare_accounts))
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index d40ed91..5ebfa04 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -2,7 +2,6 @@
# License: GNU General Public License v3. See license.txt
-import functools
import json
import os
@@ -13,7 +12,6 @@
from frappe.contacts.address_and_contact import load_address_and_contact
from frappe.utils import cint, formatdate, get_timestamp, today
from frappe.utils.nestedset import NestedSet
-from past.builtins import cmp
from erpnext.accounts.doctype.account.account import get_account_currency
from erpnext.setup.setup_wizard.operations.taxes_setup import setup_taxes_and_charges
@@ -583,7 +581,7 @@
return existing_address
if out:
- return sorted(out, key = functools.cmp_to_key(lambda x,y: cmp(y[1], x[1])))[0][0]
+ return min(out, key=lambda x: x[1])[0] # find min by sort_key
else:
return None