Use range instead xrange (#13128)

* Use range instead of xrange

* convert float to int
This commit is contained in:
Achilles Rasquinha
2018-02-28 16:12:51 +05:30
committed by Faris Ansari
parent 72d8509b3d
commit 96698c9a77
19 changed files with 38 additions and 38 deletions

View File

@@ -63,7 +63,7 @@ def simulate(domain='Manufacturing', days=100):
# runs_for = 100
fixed_asset.work()
for i in xrange(runs_for):
for i in range(runs_for):
sys.stdout.write("\rSimulating {0}: Day {1}".format(
current_date.strftime("%Y-%m-%d"), i))
sys.stdout.flush()

View File

@@ -65,7 +65,7 @@ def make_appointment():
i += 1
def make_consulation():
for i in xrange(3):
for i in range(3):
physician = get_random("Physician")
department = frappe.get_value("Physician", physician, "department")
patient = get_random("Patient")
@@ -74,7 +74,7 @@ def make_consulation():
consultation.save(ignore_permissions=True)
def consulation_on_appointment():
for i in xrange(3):
for i in range(3):
appointment = get_random("Patient Appointment")
appointment = frappe.get_doc("Patient Appointment",appointment)
consultation = set_consultation(appointment.patient, appointment.patient_sex, appointment.physician, appointment.department, appointment.appointment_date, i)

View File

@@ -80,7 +80,7 @@ def setup_demo_page():
def setup_fiscal_year():
fiscal_year = None
for year in xrange(2010, now_datetime().year + 1, 1):
for year in range(2010, now_datetime().year + 1, 1):
try:
fiscal_year = frappe.get_doc({
"doctype": "Fiscal Year",

View File

@@ -15,7 +15,7 @@ from erpnext.education.api import get_student_group_students, make_attendance_re
def work():
frappe.set_user(frappe.db.get_global('demo_education_user'))
for d in xrange(20):
for d in range(20):
approve_random_student_applicant()
enroll_random_student(frappe.flags.current_date)
# if frappe.flags.current_date.weekday()== 0:
@@ -94,7 +94,7 @@ def make_course_schedule(start_date, end_date):
cs.course_start_date = cstr(start_date)
cs.course_end_date = cstr(end_date)
day = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
for x in xrange(3):
for x in range(3):
random_day = random.choice(day)
cs.day = random_day
cs.from_time = timedelta(hours=(random.randrange(7, 17,1)))

View File

@@ -116,7 +116,7 @@ def make_material_request(item_code, qty):
return mr
def add_suppliers(rfq):
for i in xrange(2):
for i in range(2):
supplier = get_random("Supplier")
if supplier not in [d.supplier for d in rfq.get('suppliers')]:
rfq.append("suppliers", { "supplier": supplier })

View File

@@ -13,27 +13,27 @@ from erpnext.accounts.doctype.payment_request.payment_request import make_paymen
def work():
frappe.set_user(frappe.db.get_global('demo_sales_user_2'))
if random.random() < 0.5:
for i in xrange(random.randint(1,7)):
for i in range(random.randint(1,7)):
make_opportunity()
if random.random() < 0.5:
for i in xrange(random.randint(1,3)):
for i in range(random.randint(1,3)):
make_quotation()
# lost quotations / inquiries
if random.random() < 0.3:
for i in xrange(random.randint(1,3)):
for i in range(random.randint(1,3)):
quotation = get_random('Quotation', doc=True)
if quotation and quotation.status == 'Submitted':
quotation.declare_order_lost('Did not ask')
for i in xrange(random.randint(1,3)):
for i in range(random.randint(1,3)):
opportunity = get_random('Opportunity', doc=True)
if opportunity and opportunity.status in ('Open', 'Replied'):
opportunity.declare_enquiry_lost('Did not ask')
if random.random() < 0.3:
for i in xrange(random.randint(1,3)):
for i in range(random.randint(1,3)):
make_sales_order()
if random.random() < 0.1: