Browse Source

xrange to range (#3237)

* introduces build status for local fork

* converts xrange to range using six.moves.range7

* converts xrange to range using six.moves.range7

* converts xrange to range using six.moves.range7

* converts xrange to range using six.moves.range

* converts xrange to range using six.moves.range

* converts xrange to range using six.moves.range7

* converts xrange to range using six.moves.range7

* converts xrange to range using six.moves.range7

* converts xrange to range using six.moves.range7

* converts xrange to range using six.moves.range7

* converts xrange to range using six.moves.range7

* converts xrange to range using six.moves.range7

* converts xrange to range using six.moves.range7

* Revert "introduces build status for local fork"

This reverts commit 61f40983d0.
version-14
tundebabzy 8 years ago
committed by Rushabh Mehta
parent
commit
6e29d9e925
13 changed files with 28 additions and 15 deletions
  1. +2
    -1
      frappe/core/doctype/communication/email.py
  2. +2
    -1
      frappe/core/page/data_import_tool/importer.py
  3. +4
    -3
      frappe/desk/doctype/event/event.py
  4. +2
    -1
      frappe/desk/report_dump.py
  5. +2
    -1
      frappe/desk/reportview.py
  6. +2
    -1
      frappe/email/queue.py
  7. +2
    -1
      frappe/email/receive.py
  8. +2
    -1
      frappe/geo/report/addresses_and_contacts/addresses_and_contacts.py
  9. +2
    -1
      frappe/model/meta.py
  10. +2
    -1
      frappe/model/utils/__init__.py
  11. +2
    -1
      frappe/permissions.py
  12. +2
    -1
      frappe/utils/change_log.py
  13. +2
    -1
      frappe/utils/make_random.py

+ 2
- 1
frappe/core/doctype/communication/email.py View File

@@ -2,6 +2,7 @@
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals, absolute_import from __future__ import unicode_literals, absolute_import
from six.moves import range
import frappe import frappe
import json import json
from email.utils import formataddr, parseaddr from email.utils import formataddr, parseaddr
@@ -417,7 +418,7 @@ def sendmail(communication_name, print_html=None, print_format=None, attachments
frappe.local.session.update(session) frappe.local.session.update(session)


# upto 3 retries # upto 3 retries
for i in xrange(3):
for i in range(3):
try: try:
communication = frappe.get_doc("Communication", communication_name) communication = frappe.get_doc("Communication", communication_name)
communication._notify(print_html=print_html, print_format=print_format, attachments=attachments, communication._notify(print_html=print_html, print_format=print_format, attachments=attachments,


+ 2
- 1
frappe/core/page/data_import_tool/importer.py View File

@@ -3,6 +3,7 @@


from __future__ import unicode_literals, print_function from __future__ import unicode_literals, print_function


from six.moves import range
import requests import requests
import frappe, json import frappe, json
import frappe.permissions import frappe.permissions
@@ -102,7 +103,7 @@ def upload(rows = None, submit_after_import=None, ignore_encoding_errors=False,
def get_doc(start_idx): def get_doc(start_idx):
if doctypes: if doctypes:
doc = {} doc = {}
for idx in xrange(start_idx, len(rows)):
for idx in range(start_idx, len(rows)):
if (not doc) or main_doc_empty(rows[idx]): if (not doc) or main_doc_empty(rows[idx]):
for dt, parentfield in doctypes: for dt, parentfield in doctypes:
d = {} d = {}


+ 4
- 3
frappe/desk/doctype/event/event.py View File

@@ -2,6 +2,7 @@
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals from __future__ import unicode_literals
from six.moves import range
import frappe import frappe
import json import json


@@ -147,7 +148,7 @@ def get_events(start, end, user=None, for_reminder=False, filters=None):
date = date[0] + "-" + str(cint(date[1]) - 1) + "-" + date[2] date = date[0] + "-" + str(cint(date[1]) - 1) + "-" + date[2]


start_from = date start_from = date
for i in xrange(int(date_diff(end, start) / 30) + 3):
for i in range(int(date_diff(end, start) / 30) + 3):
if getdate(date) >= getdate(start) and getdate(date) <= getdate(end) \ if getdate(date) >= getdate(start) and getdate(date) <= getdate(end) \
and getdate(date) <= getdate(repeat) and getdate(date) >= getdate(event_start): and getdate(date) <= getdate(repeat) and getdate(date) >= getdate(event_start):
add_event(e, date) add_event(e, date)
@@ -163,7 +164,7 @@ def get_events(start, end, user=None, for_reminder=False, filters=None):
# start from nearest weeday after last monday # start from nearest weeday after last monday
date = add_days(start, weekday - start_weekday) date = add_days(start, weekday - start_weekday)


for cnt in xrange(int(date_diff(end, start) / 7) + 3):
for cnt in range(int(date_diff(end, start) / 7) + 3):
if getdate(date) >= getdate(start) and getdate(date) <= getdate(end) \ if getdate(date) >= getdate(start) and getdate(date) <= getdate(end) \
and getdate(date) <= getdate(repeat) and getdate(date) >= getdate(event_start): and getdate(date) <= getdate(repeat) and getdate(date) >= getdate(event_start):
add_event(e, date) add_event(e, date)
@@ -173,7 +174,7 @@ def get_events(start, end, user=None, for_reminder=False, filters=None):
remove_events.append(e) remove_events.append(e)


if e.repeat_on=="Every Day": if e.repeat_on=="Every Day":
for cnt in xrange(date_diff(end, start) + 1):
for cnt in range(date_diff(end, start) + 1):
date = add_days(start, cnt) date = add_days(start, cnt)
if getdate(date) >= getdate(event_start) and getdate(date) <= getdate(end) \ if getdate(date) >= getdate(event_start) and getdate(date) <= getdate(end) \
and getdate(date) <= getdate(repeat) and e[weekdays[getdate(date).weekday()]]: and getdate(date) <= getdate(repeat) and e[weekdays[getdate(date).weekday()]]:


+ 2
- 1
frappe/desk/report_dump.py View File

@@ -2,6 +2,7 @@
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals from __future__ import unicode_literals
from six.moves import range
import frappe import frappe
import json import json
import copy import copy
@@ -75,7 +76,7 @@ def get_data(doctypes, last_modified):
link_map = {} link_map = {}
doctype_data = out[link[0]] doctype_data = out[link[0]]
col_idx = doctype_data["columns"].index(link[1]) col_idx = doctype_data["columns"].index(link[1])
for row_idx in xrange(len(doctype_data["data"])):
for row_idx in range(len(doctype_data["data"])):
row = doctype_data["data"][row_idx] row = doctype_data["data"][row_idx]
link_map[row[col_idx]] = row_idx link_map[row[col_idx]] = row_idx


+ 2
- 1
frappe/desk/reportview.py View File

@@ -5,6 +5,7 @@ from __future__ import unicode_literals
"""build query for doclistview and return results""" """build query for doclistview and return results"""


import frappe, json import frappe, json
from six.moves import range
import frappe.permissions import frappe.permissions
import MySQLdb import MySQLdb
from frappe.model.db_query import DatabaseQuery from frappe.model.db_query import DatabaseQuery
@@ -173,7 +174,7 @@ def append_totals_row(data):
totals.extend([""]*len(data[0])) totals.extend([""]*len(data[0]))


for row in data: for row in data:
for i in xrange(len(row)):
for i in range(len(row)):
if isinstance(row[i], (float, int)): if isinstance(row[i], (float, int)):
totals[i] = (totals[i] or 0) + row[i] totals[i] = (totals[i] or 0) + row[i]
data.append(totals) data.append(totals)


+ 2
- 1
frappe/email/queue.py View File

@@ -2,6 +2,7 @@
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals from __future__ import unicode_literals
from six.moves import range
import frappe import frappe
import HTMLParser import HTMLParser
import smtplib, quopri import smtplib, quopri
@@ -289,7 +290,7 @@ def flush(from_test=False):


make_cache_queue() make_cache_queue()


for i in xrange(cache.llen('cache_email_queue')):
for i in range(cache.llen('cache_email_queue')):
email = cache.lpop('cache_email_queue') email = cache.lpop('cache_email_queue')


if cint(frappe.defaults.get_defaults().get("hold_queue"))==1: if cint(frappe.defaults.get_defaults().get("hold_queue"))==1:


+ 2
- 1
frappe/email/receive.py View File

@@ -2,6 +2,7 @@
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals from __future__ import unicode_literals
from six.moves import range
import time, _socket, poplib, imaplib, email, email.utils, datetime, chardet, re, hashlib import time, _socket, poplib, imaplib, email, email.utils, datetime, chardet, re, hashlib
from email_reply_parser import EmailReplyParser from email_reply_parser import EmailReplyParser
from email.header import decode_header from email.header import decode_header
@@ -140,7 +141,7 @@ class EmailServer:
num = num_copy num = num_copy
if not cint(self.settings.use_imap): if not cint(self.settings.use_imap):
if num > 100 and not self.errors: if num > 100 and not self.errors:
for m in xrange(101, num+1):
for m in range(101, num+1):
self.pop.dele(m) self.pop.dele(m)


except Exception as e: except Exception as e:


+ 2
- 1
frappe/geo/report/addresses_and_contacts/addresses_and_contacts.py View File

@@ -2,6 +2,7 @@
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals from __future__ import unicode_literals
from six.moves import range
import frappe import frappe




@@ -66,7 +67,7 @@ def get_party_addresses_and_contact(party_type, party):
contacts = map(list, contacts) contacts = map(list, contacts)


max_length = max(len(addresses), len(contacts)) max_length = max(len(addresses), len(contacts))
for idx in xrange(0, max_length):
for idx in range(0, max_length):
result = list(party_detail) result = list(party_detail)


address = addresses[idx] if idx < len(addresses) else [ "" for field in field_map.get("Address", []) ] address = addresses[idx] if idx < len(addresses) else [ "" for field in field_map.get("Address", []) ]


+ 2
- 1
frappe/model/meta.py View File

@@ -16,6 +16,7 @@ Example:
''' '''


from __future__ import unicode_literals, print_function from __future__ import unicode_literals, print_function
from six.moves import range
import frappe, json, os import frappe, json, os
from frappe.utils import cstr, cint from frappe.utils import cstr, cint
from frappe.model import default_fields, no_value_fields, optional_fields from frappe.model import default_fields, no_value_fields, optional_fields
@@ -281,7 +282,7 @@ class Meta(Document):
newlist += [df for df in self.get('fields') if not df.get('is_custom_field')] newlist += [df for df in self.get('fields') if not df.get('is_custom_field')]


newlist_fieldnames = [df.fieldname for df in newlist] newlist_fieldnames = [df.fieldname for df in newlist]
for i in xrange(2):
for i in range(2):
for df in list(custom_fields): for df in list(custom_fields):
if df.insert_after in newlist_fieldnames: if df.insert_after in newlist_fieldnames:
cf = custom_fields.pop(custom_fields.index(df)) cf = custom_fields.pop(custom_fields.index(df))


+ 2
- 1
frappe/model/utils/__init__.py View File

@@ -2,6 +2,7 @@
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals, print_function from __future__ import unicode_literals, print_function
from six.moves import range
import frappe import frappe
from frappe.utils import cstr from frappe.utils import cstr
from frappe.build import html_to_js_template from frappe.build import html_to_js_template
@@ -41,7 +42,7 @@ def render_include(content):
content = cstr(content) content = cstr(content)


# try 5 levels of includes # try 5 levels of includes
for i in xrange(5):
for i in range(5):
if "{% include" in content: if "{% include" in content:
paths = re.findall(r'''{% include\s['"](.*)['"]\s%}''', content) paths = re.findall(r'''{% include\s['"](.*)['"]\s%}''', content)
if not paths: if not paths:


+ 2
- 1
frappe/permissions.py View File

@@ -2,6 +2,7 @@
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals, print_function from __future__ import unicode_literals, print_function
from six.moves import range
import frappe, copy, json import frappe, copy, json
from frappe import _, msgprint from frappe import _, msgprint
from frappe.utils import cint from frappe.utils import cint
@@ -435,7 +436,7 @@ def get_user_permission_doctypes(user_permission_doctypes, user_permissions):
# for example, [["Blogger", "Blog Category"], ["Blogger"]], should only search in [["Blogger"]] as the first and condition becomes redundant # for example, [["Blogger", "Blog Category"], ["Blogger"]], should only search in [["Blogger"]] as the first and condition becomes redundant


common = user_permission_doctypes[0] common = user_permission_doctypes[0]
for i in xrange(1, len(user_permission_doctypes), 1):
for i in range(1, len(user_permission_doctypes), 1):
common = list(set(common).intersection(set(user_permission_doctypes[i]))) common = list(set(common).intersection(set(user_permission_doctypes[i])))
if not common: if not common:
break break


+ 2
- 1
frappe/utils/change_log.py View File

@@ -2,6 +2,7 @@
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals from __future__ import unicode_literals
from six.moves import range
import json, subprocess, os import json, subprocess, os
from semantic_version import Version from semantic_version import Version
import frappe import frappe
@@ -53,7 +54,7 @@ def get_change_log_for_app(app, from_version, to_version):
# remove pre-release part # remove pre-release part
to_version.prerelease = None to_version.prerelease = None


major_version_folders = ["v{0}".format(i) for i in xrange(from_version.major, to_version.major + 1)]
major_version_folders = ["v{0}".format(i) for i in range(from_version.major, to_version.major + 1)]
app_change_log = [] app_change_log = []


for folder in os.listdir(change_log_folder): for folder in os.listdir(change_log_folder):


+ 2
- 1
frappe/utils/make_random.py View File

@@ -1,4 +1,5 @@
import frappe, random import frappe, random
from six.moves import range


settings = frappe._dict( settings = frappe._dict(
prob = { prob = {
@@ -11,7 +12,7 @@ def add_random_children(doc, fieldname, rows, randomize, unique=None):
if rows > 1: if rows > 1:
nrows = random.randrange(1, rows) nrows = random.randrange(1, rows)


for i in xrange(nrows):
for i in range(nrows):
d = {} d = {}
for key, val in randomize.items(): for key, val in randomize.items():
if isinstance(val[0], basestring): if isinstance(val[0], basestring):


Loading…
Cancel
Save