Просмотр исходного кода

chore: Drop dead and deprecated code

* Remove six for PY2 compatability since our dependencies are not, PY2
  is legacy.
* Removed usages of utils from future/past libraries since they are
  deprecated. This includes 'from __future__ ...' and 'from past...'
  statements.
* Removed compatibility imports for PY2, switched from six imports to
  standard library imports.
* Removed utils code blocks that handle operations depending on PY2/3
  versions.
* Removed 'from __future__ ...' lines from templates/code generators
* Used PY3 syntaxes in place of PY2 compatible blocks. eg: metaclass
version-14
Gavin D'souza 4 лет назад
Родитель
Сommit
e407b78506
100 измененных файлов: 53 добавлений и 221 удалений
  1. +0
    -1
      frappe/api.py
  2. +3
    -4
      frappe/app.py
  3. +1
    -5
      frappe/auth.py
  4. +0
    -2
      frappe/automation/doctype/assignment_rule/assignment_rule.py
  5. +0
    -2
      frappe/automation/doctype/assignment_rule/test_assignment_rule.py
  6. +0
    -1
      frappe/automation/doctype/assignment_rule_day/assignment_rule_day.py
  7. +0
    -1
      frappe/automation/doctype/assignment_rule_user/assignment_rule_user.py
  8. +0
    -1
      frappe/automation/doctype/auto_repeat/auto_repeat.py
  9. +0
    -2
      frappe/automation/doctype/auto_repeat/test_auto_repeat.py
  10. +0
    -1
      frappe/automation/doctype/auto_repeat_day/auto_repeat_day.py
  11. +0
    -2
      frappe/automation/doctype/milestone/milestone.py
  12. +0
    -2
      frappe/automation/doctype/milestone/test_milestone.py
  13. +0
    -2
      frappe/automation/doctype/milestone_tracker/milestone_tracker.py
  14. +0
    -2
      frappe/automation/doctype/milestone_tracker/test_milestone_tracker.py
  15. +2
    -7
      frappe/boot.py
  16. +1
    -3
      frappe/build.py
  17. +0
    -2
      frappe/cache_manager.py
  18. +1
    -1
      frappe/chat/__init__.py
  19. +0
    -2
      frappe/chat/doctype/chat_message/chat_message.py
  20. +0
    -2
      frappe/chat/doctype/chat_profile/chat_profile.py
  21. +0
    -2
      frappe/chat/doctype/chat_room/chat_room.py
  22. +0
    -2
      frappe/chat/doctype/chat_room_user/chat_room_user.py
  23. +0
    -1
      frappe/chat/doctype/chat_token/chat_token.py
  24. +0
    -2
      frappe/chat/util/__init__.py
  25. +1
    -4
      frappe/chat/util/test_util.py
  26. +0
    -2
      frappe/chat/util/util.py
  27. +1
    -1
      frappe/chat/website/__init__.py
  28. +8
    -11
      frappe/client.py
  29. +1
    -2
      frappe/commands/__init__.py
  30. +0
    -1
      frappe/commands/scheduler.py
  31. +0
    -1
      frappe/commands/translate.py
  32. +1
    -1
      frappe/commands/utils.py
  33. +0
    -3
      frappe/config/__init__.py
  34. +0
    -1
      frappe/contacts/address_and_contact.py
  35. +0
    -2
      frappe/contacts/doctype/address/test_address.py
  36. +0
    -1
      frappe/contacts/doctype/address_template/address_template.py
  37. +1
    -3
      frappe/contacts/doctype/address_template/test_address_template.py
  38. +0
    -1
      frappe/contacts/doctype/contact/contact.py
  39. +0
    -2
      frappe/contacts/doctype/contact/test_contact.py
  40. +0
    -1
      frappe/contacts/doctype/contact_email/contact_email.py
  41. +0
    -1
      frappe/contacts/doctype/contact_phone/contact_phone.py
  42. +0
    -1
      frappe/contacts/doctype/gender/gender.py
  43. +0
    -2
      frappe/contacts/doctype/gender/test_gender.py
  44. +0
    -1
      frappe/contacts/doctype/salutation/salutation.py
  45. +0
    -2
      frappe/contacts/doctype/salutation/test_salutation.py
  46. +1
    -4
      frappe/contacts/report/addresses_and_contacts/addresses_and_contacts.py
  47. +1
    -1
      frappe/contacts/report/addresses_and_contacts/test_addresses_and_contacts.py
  48. +0
    -2
      frappe/core/__init__.py
  49. +0
    -1
      frappe/core/doctype/__init__.py
  50. +0
    -2
      frappe/core/doctype/access_log/access_log.py
  51. +0
    -1
      frappe/core/doctype/activity_log/activity_log.py
  52. +1
    -3
      frappe/core/doctype/activity_log/feed.py
  53. +0
    -2
      frappe/core/doctype/activity_log/test_activity_log.py
  54. +0
    -1
      frappe/core/doctype/block_module/block_module.py
  55. +0
    -2
      frappe/core/doctype/comment/comment.py
  56. +0
    -2
      frappe/core/doctype/comment/test_comment.py
  57. +1
    -2
      frappe/core/doctype/communication/communication.py
  58. +4
    -7
      frappe/core/doctype/communication/email.py
  59. +1
    -3
      frappe/core/doctype/communication/test_communication.py
  60. +0
    -1
      frappe/core/doctype/communication_link/communication_link.py
  61. +0
    -1
      frappe/core/doctype/custom_docperm/custom_docperm.py
  62. +0
    -2
      frappe/core/doctype/custom_docperm/test_custom_docperm.py
  63. +0
    -1
      frappe/core/doctype/custom_role/custom_role.py
  64. +0
    -2
      frappe/core/doctype/custom_role/test_custom_role.py
  65. +0
    -1
      frappe/core/doctype/data_export/data_export.py
  66. +1
    -4
      frappe/core/doctype/data_export/exporter.py
  67. +0
    -1
      frappe/core/doctype/data_import/importer.py
  68. +0
    -2
      frappe/core/doctype/data_import/test_data_import.py
  69. +0
    -2
      frappe/core/doctype/data_import/test_exporter.py
  70. +0
    -2
      frappe/core/doctype/data_import/test_importer.py
  71. +2
    -6
      frappe/core/doctype/data_import_legacy/importer.py
  72. +0
    -2
      frappe/core/doctype/data_import_legacy/test_data_import_legacy.py
  73. +0
    -1
      frappe/core/doctype/defaultvalue/__init__.py
  74. +0
    -1
      frappe/core/doctype/defaultvalue/defaultvalue.py
  75. +0
    -1
      frappe/core/doctype/deleted_document/deleted_document.py
  76. +0
    -2
      frappe/core/doctype/deleted_document/test_deleted_document.py
  77. +0
    -1
      frappe/core/doctype/docfield/__init__.py
  78. +0
    -2
      frappe/core/doctype/docfield/docfield.py
  79. +0
    -1
      frappe/core/doctype/docperm/__init__.py
  80. +0
    -1
      frappe/core/doctype/docperm/docperm.py
  81. +0
    -1
      frappe/core/doctype/docshare/docshare.py
  82. +0
    -1
      frappe/core/doctype/docshare/test_docshare.py
  83. +0
    -1
      frappe/core/doctype/doctype/__init__.py
  84. +2
    -7
      frappe/core/doctype/doctype/doctype.py
  85. +0
    -2
      frappe/core/doctype/doctype/test_doctype.py
  86. +0
    -1
      frappe/core/doctype/doctype_action/doctype_action.py
  87. +0
    -1
      frappe/core/doctype/doctype_link/doctype_link.py
  88. +0
    -1
      frappe/core/doctype/document_naming_rule/document_naming_rule.py
  89. +0
    -2
      frappe/core/doctype/document_naming_rule/test_document_naming_rule.py
  90. +0
    -1
      frappe/core/doctype/document_naming_rule_condition/document_naming_rule_condition.py
  91. +0
    -2
      frappe/core/doctype/document_naming_rule_condition/test_document_naming_rule_condition.py
  92. +0
    -1
      frappe/core/doctype/domain/domain.py
  93. +0
    -2
      frappe/core/doctype/domain/test_domain.py
  94. +0
    -1
      frappe/core/doctype/domain_settings/domain_settings.py
  95. +0
    -1
      frappe/core/doctype/dynamic_link/dynamic_link.py
  96. +0
    -1
      frappe/core/doctype/error_log/error_log.py
  97. +0
    -2
      frappe/core/doctype/error_log/test_error_log.py
  98. +0
    -1
      frappe/core/doctype/error_snapshot/error_snapshot.py
  99. +0
    -2
      frappe/core/doctype/error_snapshot/test_error_snapshot.py
  100. +18
    -24
      frappe/core/doctype/file/file.py

+ 0
- 1
frappe/api.py Просмотреть файл

@@ -1,6 +1,5 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt

import base64 import base64
import binascii import binascii
import json import json


+ 3
- 4
frappe/app.py Просмотреть файл

@@ -1,10 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt
from __future__ import unicode_literals


import os import os
from six import iteritems
import logging import logging


from werkzeug.local import LocalManager from werkzeug.local import LocalManager
@@ -191,8 +189,9 @@ def make_form_dict(request):
frappe.throw(_("Invalid request arguments")) frappe.throw(_("Invalid request arguments"))


try: try:
frappe.local.form_dict = frappe._dict({ k:v[0] if isinstance(v, (list, tuple)) else v \
for k, v in iteritems(args) })
frappe.local.form_dict = frappe._dict({
k: v[0] if isinstance(v, (list, tuple)) else v for k, v in args.items()
})
except IndexError: except IndexError:
frappe.local.form_dict = frappe._dict(args) frappe.local.form_dict = frappe._dict(args)




+ 1
- 5
frappe/auth.py Просмотреть файл

@@ -1,9 +1,6 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt

from __future__ import unicode_literals
import datetime import datetime

from frappe import _ from frappe import _
import frappe import frappe
import frappe.database import frappe.database
@@ -19,8 +16,7 @@ from frappe.core.doctype.activity_log.activity_log import add_authentication_log
from frappe.twofactor import (should_run_2fa, authenticate_for_2factor, from frappe.twofactor import (should_run_2fa, authenticate_for_2factor,
confirm_otp_token, get_cached_user_pass) confirm_otp_token, get_cached_user_pass)
from frappe.website.utils import get_home_page from frappe.website.utils import get_home_page

from six.moves.urllib.parse import quote
from urllib.parse import quote




class HTTPRequest: class HTTPRequest:


+ 0
- 2
frappe/automation/doctype/assignment_rule/assignment_rule.py Просмотреть файл

@@ -2,8 +2,6 @@
# Copyright (c) 2019, Frappe Technologies and contributors # Copyright (c) 2019, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals

import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document
from frappe.desk.form import assign_to from frappe.desk.form import assign_to


+ 0
- 2
frappe/automation/doctype/assignment_rule/test_assignment_rule.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies and Contributors # Copyright (c) 2019, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import frappe import frappe
import unittest import unittest
from frappe.utils import random_string from frappe.utils import random_string


+ 0
- 1
frappe/automation/doctype/assignment_rule_day/assignment_rule_day.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2019, Frappe Technologies and contributors # Copyright (c) 2019, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
# import frappe # import frappe
from frappe.model.document import Document from frappe.model.document import Document




+ 0
- 1
frappe/automation/doctype/assignment_rule_user/assignment_rule_user.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2019, Frappe Technologies and contributors # Copyright (c) 2019, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
# import frappe # import frappe
from frappe.model.document import Document from frappe.model.document import Document




+ 0
- 1
frappe/automation/doctype/auto_repeat/auto_repeat.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
import frappe import frappe
from frappe import _ from frappe import _
from datetime import timedelta from datetime import timedelta


+ 0
- 2
frappe/automation/doctype/auto_repeat/test_auto_repeat.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2018, Frappe Technologies and Contributors # Copyright (c) 2018, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import unittest import unittest


import frappe import frappe


+ 0
- 1
frappe/automation/doctype/auto_repeat_day/auto_repeat_day.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2020, Frappe Technologies and contributors # Copyright (c) 2020, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
# import frappe # import frappe
from frappe.model.document import Document from frappe.model.document import Document




+ 0
- 2
frappe/automation/doctype/milestone/milestone.py Просмотреть файл

@@ -2,8 +2,6 @@
# Copyright (c) 2019, Frappe Technologies and contributors # Copyright (c) 2019, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals

import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document




+ 0
- 2
frappe/automation/doctype/milestone/test_milestone.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies and Contributors # Copyright (c) 2019, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

#import frappe #import frappe
import unittest import unittest




+ 0
- 2
frappe/automation/doctype/milestone_tracker/milestone_tracker.py Просмотреть файл

@@ -2,8 +2,6 @@
# Copyright (c) 2019, Frappe Technologies and contributors # Copyright (c) 2019, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals

import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document
import frappe.cache_manager import frappe.cache_manager


+ 0
- 2
frappe/automation/doctype/milestone_tracker/test_milestone_tracker.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies and Contributors # Copyright (c) 2019, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import frappe import frappe
import frappe.cache_manager import frappe.cache_manager
import unittest import unittest


+ 2
- 7
frappe/boot.py Просмотреть файл

@@ -1,10 +1,5 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt

from __future__ import unicode_literals

from six import iteritems, text_type

""" """
bootstrap client session bootstrap client session
""" """
@@ -75,7 +70,7 @@ def get_bootinfo():
frappe.get_attr(method)(bootinfo) frappe.get_attr(method)(bootinfo)


if bootinfo.lang: if bootinfo.lang:
bootinfo.lang = text_type(bootinfo.lang)
bootinfo.lang = str(bootinfo.lang)
bootinfo.versions = {k: v['version'] for k, v in get_versions().items()} bootinfo.versions = {k: v['version'] for k, v in get_versions().items()}


bootinfo.error_report_email = frappe.conf.error_report_email bootinfo.error_report_email = frappe.conf.error_report_email
@@ -220,7 +215,7 @@ def load_translations(bootinfo):
messages[name] = frappe._(name) messages[name] = frappe._(name)


# only untranslated # only untranslated
messages = {k:v for k, v in iteritems(messages) if k!=v}
messages = {k: v for k, v in messages.items() if k!=v}


bootinfo["__messages"] = messages bootinfo["__messages"] = messages




+ 1
- 3
frappe/build.py Просмотреть файл

@@ -1,11 +1,11 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt

import os import os
import re import re
import json import json
import shutil import shutil
import subprocess import subprocess
from io import StringIO
from tempfile import mkdtemp, mktemp from tempfile import mkdtemp, mktemp
from distutils.spawn import find_executable from distutils.spawn import find_executable


@@ -402,8 +402,6 @@ def get_build_maps():




def pack(target, sources, no_compress, verbose): def pack(target, sources, no_compress, verbose):
from six import StringIO

outtype, outtxt = target.split(".")[-1], "" outtype, outtxt = target.split(".")[-1], ""
jsm = JavascriptMinify() jsm = JavascriptMinify()




+ 0
- 2
frappe/cache_manager.py Просмотреть файл

@@ -1,8 +1,6 @@
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals

import frappe, json import frappe, json
from frappe.model.document import Document from frappe.model.document import Document
from frappe.desk.notifications import (delete_notification_count_for, from frappe.desk.notifications import (delete_notification_count_for,


+ 1
- 1
frappe/chat/__init__.py Просмотреть файл

@@ -1,4 +1,4 @@
from __future__ import unicode_literals
import frappe import frappe
from frappe import _ from frappe import _




+ 0
- 2
frappe/chat/doctype/chat_message/chat_message.py Просмотреть файл

@@ -1,5 +1,3 @@
from __future__ import unicode_literals

# imports - standard imports # imports - standard imports
import json import json




+ 0
- 2
frappe/chat/doctype/chat_profile/chat_profile.py Просмотреть файл

@@ -1,5 +1,3 @@
from __future__ import unicode_literals

# imports - module imports # imports - module imports
from frappe.model.document import Document from frappe.model.document import Document
from frappe import _ from frappe import _


+ 0
- 2
frappe/chat/doctype/chat_room/chat_room.py Просмотреть файл

@@ -1,5 +1,3 @@
from __future__ import unicode_literals

# imports - module imports # imports - module imports
from frappe.model.document import Document from frappe.model.document import Document
from frappe import _ from frappe import _


+ 0
- 2
frappe/chat/doctype/chat_room_user/chat_room_user.py Просмотреть файл

@@ -1,5 +1,3 @@
from __future__ import unicode_literals

# imports - module imports # imports - module imports
from frappe.model.document import Document from frappe.model.document import Document
import frappe import frappe


+ 0
- 1
frappe/chat/doctype/chat_token/chat_token.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2018, Frappe Technologies and contributors # Copyright (c) 2018, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document




+ 0
- 2
frappe/chat/util/__init__.py Просмотреть файл

@@ -1,5 +1,3 @@
from __future__ import unicode_literals

# imports - module imports # imports - module imports
from frappe.chat.util.util import ( from frappe.chat.util.util import (
get_user_doc, get_user_doc,


+ 1
- 4
frappe/chat/util/test_util.py Просмотреть файл

@@ -1,5 +1,3 @@
from __future__ import unicode_literals

# imports - standard imports # imports - standard imports
import unittest import unittest


@@ -9,7 +7,6 @@ from frappe.chat.util import (
safe_json_loads safe_json_loads
) )
import frappe import frappe
import six


class TestChatUtil(unittest.TestCase): class TestChatUtil(unittest.TestCase):
def test_safe_json_loads(self): def test_safe_json_loads(self):
@@ -20,7 +17,7 @@ class TestChatUtil(unittest.TestCase):
self.assertEqual(type(number), float) self.assertEqual(type(number), float)


string = safe_json_loads("foobar") string = safe_json_loads("foobar")
self.assertEqual(type(string), six.text_type)
self.assertEqual(type(string), str)


array = safe_json_loads('[{ "foo": "bar" }]') array = safe_json_loads('[{ "foo": "bar" }]')
self.assertEqual(type(array), list) self.assertEqual(type(array), list)


+ 0
- 2
frappe/chat/util/util.py Просмотреть файл

@@ -1,5 +1,3 @@
from __future__ import unicode_literals

# imports - standard imports # imports - standard imports
import json import json
from collections.abc import MutableMapping, MutableSequence, Sequence from collections.abc import MutableMapping, MutableSequence, Sequence


+ 1
- 1
frappe/chat/website/__init__.py Просмотреть файл

@@ -1,4 +1,4 @@
from __future__ import unicode_literals
import frappe import frappe
from frappe.chat.util import filter_dict, safe_json_loads from frappe.chat.util import filter_dict, safe_json_loads




+ 8
- 11
frappe/client.py Просмотреть файл

@@ -1,7 +1,5 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt

from __future__ import unicode_literals
import frappe import frappe
from frappe import _ from frappe import _
import frappe.model import frappe.model
@@ -11,7 +9,6 @@ from frappe.utils import get_safe_filters
from frappe.desk.reportview import validate_args from frappe.desk.reportview import validate_args
from frappe.model.db_query import check_parent_permission from frappe.model.db_query import check_parent_permission


from six import iteritems, string_types, integer_types


''' '''
Handle RESTful requests that are mapped to the `/api/resource` route. Handle RESTful requests that are mapped to the `/api/resource` route.
@@ -86,7 +83,7 @@ def get_value(doctype, fieldname, filters=None, as_dict=True, debug=False, paren
frappe.throw(_("No permission for {0}").format(doctype), frappe.PermissionError) frappe.throw(_("No permission for {0}").format(doctype), frappe.PermissionError)


filters = get_safe_filters(filters) filters = get_safe_filters(filters)
if isinstance(filters, string_types):
if isinstance(filters, str):
filters = {"name": filters} filters = {"name": filters}


try: try:
@@ -135,7 +132,7 @@ def set_value(doctype, name, fieldname, value=None):


if not value: if not value:
values = fieldname values = fieldname
if isinstance(fieldname, string_types):
if isinstance(fieldname, str):
try: try:
values = json.loads(fieldname) values = json.loads(fieldname)
except ValueError: except ValueError:
@@ -161,7 +158,7 @@ def insert(doc=None):
'''Insert a document '''Insert a document


:param doc: JSON or dict object to be inserted''' :param doc: JSON or dict object to be inserted'''
if isinstance(doc, string_types):
if isinstance(doc, str):
doc = json.loads(doc) doc = json.loads(doc)


if doc.get("parent") and doc.get("parenttype"): if doc.get("parent") and doc.get("parenttype"):
@@ -179,7 +176,7 @@ def insert_many(docs=None):
'''Insert multiple documents '''Insert multiple documents


:param docs: JSON or list of dict objects to be inserted in one request''' :param docs: JSON or list of dict objects to be inserted in one request'''
if isinstance(docs, string_types):
if isinstance(docs, str):
docs = json.loads(docs) docs = json.loads(docs)


out = [] out = []
@@ -205,7 +202,7 @@ def save(doc):
'''Update (save) an existing document '''Update (save) an existing document


:param doc: JSON or dict object with the properties of the document to be updated''' :param doc: JSON or dict object with the properties of the document to be updated'''
if isinstance(doc, string_types):
if isinstance(doc, str):
doc = json.loads(doc) doc = json.loads(doc)


doc = frappe.get_doc(doc) doc = frappe.get_doc(doc)
@@ -228,7 +225,7 @@ def submit(doc):
'''Submit a document '''Submit a document


:param doc: JSON or dict object to be submitted remotely''' :param doc: JSON or dict object to be submitted remotely'''
if isinstance(doc, string_types):
if isinstance(doc, str):
doc = json.loads(doc) doc = json.loads(doc)


doc = frappe.get_doc(doc) doc = frappe.get_doc(doc)
@@ -266,7 +263,7 @@ def make_width_property_setter(doc):
'''Set width Property Setter '''Set width Property Setter


:param doc: Property Setter document with `width` property''' :param doc: Property Setter document with `width` property'''
if isinstance(doc, string_types):
if isinstance(doc, str):
doc = json.loads(doc) doc = json.loads(doc)
if doc["doctype"]=="Property Setter" and doc["property"]=="width": if doc["doctype"]=="Property Setter" and doc["property"]=="width":
frappe.get_doc(doc).insert(ignore_permissions = True) frappe.get_doc(doc).insert(ignore_permissions = True)
@@ -280,7 +277,7 @@ def bulk_update(docs):
failed_docs = [] failed_docs = []
for doc in docs: for doc in docs:
try: try:
ddoc = {key: val for key, val in iteritems(doc) if key not in ['doctype', 'docname']}
ddoc = {key: val for key, val in doc.items() if key not in ['doctype', 'docname']}
doctype = doc['doctype'] doctype = doc['doctype']
docname = doc['docname'] docname = doc['docname']
doc = frappe.get_doc(doctype, docname) doc = frappe.get_doc(doctype, docname)


+ 1
- 2
frappe/commands/__init__.py Просмотреть файл

@@ -1,7 +1,6 @@
# Copyright (c) 2015, Web Notes Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Web Notes Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals, absolute_import, print_function
import sys import sys
import click import click
import cProfile import cProfile
@@ -10,7 +9,7 @@ import frappe
import frappe.utils import frappe.utils
import subprocess # nosec import subprocess # nosec
from functools import wraps from functools import wraps
from six import StringIO
from io import StringIO
from os import environ from os import environ


click.disable_unicode_literals_warning = True click.disable_unicode_literals_warning = True


+ 0
- 1
frappe/commands/scheduler.py Просмотреть файл

@@ -1,4 +1,3 @@
from __future__ import unicode_literals, absolute_import, print_function
import click import click
import sys import sys
import frappe import frappe


+ 0
- 1
frappe/commands/translate.py Просмотреть файл

@@ -1,4 +1,3 @@
from __future__ import unicode_literals, absolute_import, print_function
import click import click
from frappe.commands import pass_context, get_site from frappe.commands import pass_context, get_site
from frappe.exceptions import SiteNotSpecifiedError from frappe.exceptions import SiteNotSpecifiedError


+ 1
- 1
frappe/commands/utils.py Просмотреть файл

@@ -222,7 +222,7 @@ def execute(context, method, args=None, kwargs=None, profile=False):


if profile: if profile:
import pstats import pstats
from six import StringIO
from io import StringIO


pr.disable() pr.disable()
s = StringIO() s = StringIO()


+ 0
- 3
frappe/config/__init__.py Просмотреть файл

@@ -1,6 +1,3 @@
from __future__ import unicode_literals
import json
from six import iteritems
import frappe import frappe
from frappe import _ from frappe import _
from frappe.desk.moduleview import (get_data, get_onboard_items, config_exists, get_module_link_items_from_list) from frappe.desk.moduleview import (get_data, get_onboard_items, config_exists, get_module_link_items_from_list)


+ 0
- 1
frappe/contacts/address_and_contact.py Просмотреть файл

@@ -1,7 +1,6 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt


from __future__ import unicode_literals
import frappe import frappe


from frappe import _ from frappe import _


+ 0
- 2
frappe/contacts/doctype/address/test_address.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies and Contributors # Copyright (c) 2015, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import frappe, unittest import frappe, unittest
from frappe.contacts.doctype.address.address import get_address_display from frappe.contacts.doctype.address.address import get_address_display




+ 0
- 1
frappe/contacts/doctype/address_template/address_template.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2015, Frappe Technologies and contributors # Copyright (c) 2015, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document
from frappe.utils import cint from frappe.utils import cint


+ 1
- 3
frappe/contacts/doctype/address_template/test_address_template.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies and Contributors # Copyright (c) 2015, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import frappe, unittest import frappe, unittest


class TestAddressTemplate(unittest.TestCase): class TestAddressTemplate(unittest.TestCase):
@@ -42,4 +40,4 @@ class TestAddressTemplate(unittest.TestCase):
"doctype": "Address Template", "doctype": "Address Template",
"country": 'Brazil', "country": 'Brazil',
"template": template "template": template
}).insert()
}).insert()

+ 0
- 1
frappe/contacts/doctype/contact/contact.py Просмотреть файл

@@ -1,6 +1,5 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt

import frappe import frappe
from frappe.utils import cstr, has_gravatar from frappe.utils import cstr, has_gravatar
from frappe import _ from frappe import _


+ 0
- 2
frappe/contacts/doctype/contact/test_contact.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2017, Frappe Technologies and Contributors # Copyright (c) 2017, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import frappe import frappe
import unittest import unittest




+ 0
- 1
frappe/contacts/doctype/contact_email/contact_email.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2019, Frappe Technologies and contributors # Copyright (c) 2019, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
# import frappe # import frappe
from frappe.model.document import Document from frappe.model.document import Document




+ 0
- 1
frappe/contacts/doctype/contact_phone/contact_phone.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2019, Frappe Technologies and contributors # Copyright (c) 2019, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
# import frappe # import frappe
from frappe.model.document import Document from frappe.model.document import Document




+ 0
- 1
frappe/contacts/doctype/gender/gender.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2017, Frappe Technologies and contributors # Copyright (c) 2017, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
from frappe.model.document import Document from frappe.model.document import Document


class Gender(Document): class Gender(Document):


+ 0
- 2
frappe/contacts/doctype/gender/test_gender.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2017, Frappe Technologies and Contributors # Copyright (c) 2017, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import unittest import unittest


class TestGender(unittest.TestCase): class TestGender(unittest.TestCase):


+ 0
- 1
frappe/contacts/doctype/salutation/salutation.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2017, Frappe Technologies and contributors # Copyright (c) 2017, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
from frappe.model.document import Document from frappe.model.document import Document


class Salutation(Document): class Salutation(Document):


+ 0
- 2
frappe/contacts/doctype/salutation/test_salutation.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2017, Frappe Technologies and Contributors # Copyright (c) 2017, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import unittest import unittest


class TestSalutation(unittest.TestCase): class TestSalutation(unittest.TestCase):


+ 1
- 4
frappe/contacts/report/addresses_and_contacts/addresses_and_contacts.py Просмотреть файл

@@ -1,8 +1,5 @@
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors # Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt # For license information, please see license.txt

from __future__ import unicode_literals
from six import iteritems
import frappe import frappe
from frappe import _ from frappe import _


@@ -58,7 +55,7 @@ def get_reference_addresses_and_contact(reference_doctype, reference_name):
reference_details = get_reference_details(reference_doctype, "Address", reference_list, reference_details) reference_details = get_reference_details(reference_doctype, "Address", reference_list, reference_details)
reference_details = get_reference_details(reference_doctype, "Contact", reference_list, reference_details) reference_details = get_reference_details(reference_doctype, "Contact", reference_list, reference_details)


for reference_name, details in iteritems(reference_details):
for reference_name, details in reference_details.items():
addresses = details.get("address", []) addresses = details.get("address", [])
contacts = details.get("contact", []) contacts = details.get("contact", [])
if not any([addresses, contacts]): if not any([addresses, contacts]):


+ 1
- 1
frappe/contacts/report/addresses_and_contacts/test_addresses_and_contacts.py Просмотреть файл

@@ -1,4 +1,4 @@
from __future__ import unicode_literals
import frappe import frappe
import frappe.defaults import frappe.defaults
import unittest import unittest


+ 0
- 2
frappe/core/__init__.py Просмотреть файл

@@ -1,4 +1,2 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt

from __future__ import unicode_literals

+ 0
- 1
frappe/core/doctype/__init__.py Просмотреть файл

@@ -1,4 +1,3 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals

+ 0
- 2
frappe/core/doctype/access_log/access_log.py Просмотреть файл

@@ -3,8 +3,6 @@
# For license information, please see license.txt # For license information, please see license.txt


# imports - standard imports # imports - standard imports
from __future__ import unicode_literals

# imports - module imports # imports - module imports
import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document


+ 0
- 1
frappe/core/doctype/activity_log/activity_log.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2017, Frappe Technologies and contributors # Copyright (c) 2017, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
from frappe import _ from frappe import _
from frappe.utils import get_fullname, now from frappe.utils import get_fullname, now
from frappe.model.document import Document from frappe.model.document import Document


+ 1
- 3
frappe/core/doctype/activity_log/feed.py Просмотреть файл

@@ -1,13 +1,11 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: See license.txt # License: See license.txt


from __future__ import unicode_literals
import frappe import frappe
import frappe.permissions import frappe.permissions
from frappe.utils import get_fullname from frappe.utils import get_fullname
from frappe import _ from frappe import _
from frappe.core.doctype.activity_log.activity_log import add_authentication_log from frappe.core.doctype.activity_log.activity_log import add_authentication_log
from six import string_types


def update_feed(doc, method=None): def update_feed(doc, method=None):
if frappe.flags.in_patch or frappe.flags.in_install or frappe.flags.in_import: if frappe.flags.in_patch or frappe.flags.in_install or frappe.flags.in_import:
@@ -23,7 +21,7 @@ def update_feed(doc, method=None):
feed = doc.get_feed() feed = doc.get_feed()


if feed: if feed:
if isinstance(feed, string_types):
if isinstance(feed, str):
feed = {"subject": feed} feed = {"subject": feed}


feed = frappe._dict(feed) feed = frappe._dict(feed)


+ 0
- 2
frappe/core/doctype/activity_log/test_activity_log.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies and Contributors # Copyright (c) 2015, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import frappe import frappe
import unittest import unittest
import time import time


+ 0
- 1
frappe/core/doctype/block_module/block_module.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document




+ 0
- 2
frappe/core/doctype/comment/comment.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies and contributors # Copyright (c) 2019, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt

from __future__ import unicode_literals, absolute_import
import frappe import frappe
from frappe import _ from frappe import _
import json import json


+ 0
- 2
frappe/core/doctype/comment/test_comment.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies and Contributors # Copyright (c) 2019, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import frappe, json import frappe, json
import unittest import unittest




+ 1
- 2
frappe/core/doctype/communication/communication.py Просмотреть файл

@@ -1,7 +1,6 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals, absolute_import
from collections import Counter from collections import Counter
import frappe import frappe
from frappe import _ from frappe import _
@@ -13,7 +12,7 @@ from frappe.utils.bot import BotReply
from frappe.utils import parse_addr from frappe.utils import parse_addr
from frappe.core.doctype.comment.comment import update_comment_in_doc from frappe.core.doctype.comment.comment import update_comment_in_doc
from email.utils import parseaddr from email.utils import parseaddr
from six.moves.urllib.parse import unquote
from urllib.parse import unquote
from frappe.utils.user import is_system_user from frappe.utils.user import is_system_user
from frappe.contacts.doctype.contact.contact import get_contact_name from frappe.contacts.doctype.contact.contact import get_contact_name
from frappe.automation.doctype.assignment_rule.assignment_rule import apply as apply_assignment_rule from frappe.automation.doctype.assignment_rule.assignment_rule import apply as apply_assignment_rule


+ 4
- 7
frappe/core/doctype/communication/email.py Просмотреть файл

@@ -1,9 +1,6 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals, absolute_import
from six.moves import range
from six import string_types
import frappe import frappe
import json import json
from email.utils import formataddr from email.utils import formataddr
@@ -77,7 +74,7 @@ def make(doctype=None, name=None, content=None, subject=None, sent_or_received =


comm.save(ignore_permissions=True) comm.save(ignore_permissions=True)


if isinstance(attachments, string_types):
if isinstance(attachments, str):
attachments = json.loads(attachments) attachments = json.loads(attachments)


# if not committed, delayed task doesn't find the communication # if not committed, delayed task doesn't find the communication
@@ -249,11 +246,11 @@ def prepare_to_notify(doc, print_html=None, print_format=None, attachments=None)
"name":doc.reference_name, "print_format":print_format, "html":print_html}) "name":doc.reference_name, "print_format":print_format, "html":print_html})


if attachments: if attachments:
if isinstance(attachments, string_types):
if isinstance(attachments, str):
attachments = json.loads(attachments) attachments = json.loads(attachments)


for a in attachments: for a in attachments:
if isinstance(a, string_types):
if isinstance(a, str):
# is it a filename? # is it a filename?
try: try:
# check for both filename and file id # check for both filename and file id
@@ -355,7 +352,7 @@ def add_attachments(name, attachments):
'''Add attachments to the given Communication''' '''Add attachments to the given Communication'''
# loop through attachments # loop through attachments
for a in attachments: for a in attachments:
if isinstance(a, string_types):
if isinstance(a, str):
attach = frappe.db.get_value("File", {"name":a}, attach = frappe.db.get_value("File", {"name":a},
["file_name", "file_url", "is_private"], as_dict=1) ["file_name", "file_url", "is_private"], as_dict=1)




+ 1
- 3
frappe/core/doctype/communication/test_communication.py Просмотреть файл

@@ -1,10 +1,8 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import frappe import frappe
import unittest import unittest
from six.moves.urllib.parse import quote
from urllib.parse import quote
test_records = frappe.get_test_records('Communication') test_records = frappe.get_test_records('Communication')






+ 0
- 1
frappe/core/doctype/communication_link/communication_link.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2019, Frappe Technologies and contributors # Copyright (c) 2019, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document




+ 0
- 1
frappe/core/doctype/custom_docperm/custom_docperm.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2015, Frappe Technologies and contributors # Copyright (c) 2015, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document




+ 0
- 2
frappe/core/doctype/custom_docperm/test_custom_docperm.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies and Contributors # Copyright (c) 2015, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import frappe import frappe
import unittest import unittest




+ 0
- 1
frappe/core/doctype/custom_role/custom_role.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2015, Frappe Technologies and contributors # Copyright (c) 2015, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document




+ 0
- 2
frappe/core/doctype/custom_role/test_custom_role.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies and Contributors # Copyright (c) 2015, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import frappe import frappe
import unittest import unittest




+ 0
- 1
frappe/core/doctype/data_export/data_export.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
from frappe.model.document import Document from frappe.model.document import Document


class DataExport(Document): class DataExport(Document):


+ 1
- 4
frappe/core/doctype/data_export/exporter.py Просмотреть файл

@@ -1,8 +1,6 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals

import frappe import frappe
from frappe import _ from frappe import _
import frappe.permissions import frappe.permissions
@@ -10,7 +8,6 @@ import re, csv, os
from frappe.utils.csvutils import UnicodeWriter from frappe.utils.csvutils import UnicodeWriter
from frappe.utils import cstr, formatdate, format_datetime, parse_json, cint, format_duration from frappe.utils import cstr, formatdate, format_datetime, parse_json, cint, format_duration
from frappe.core.doctype.data_import_legacy.importer import get_data_keys from frappe.core.doctype.data_import_legacy.importer import get_data_keys
from six import string_types
from frappe.core.doctype.access_log.access_log import make_access_log from frappe.core.doctype.access_log.access_log import make_access_log


reflags = { reflags = {
@@ -57,7 +54,7 @@ class DataExporter:


self.docs_to_export = {} self.docs_to_export = {}
if self.doctype: if self.doctype:
if isinstance(self.doctype, string_types):
if isinstance(self.doctype, str):
self.doctype = [self.doctype] self.doctype = [self.doctype]


if len(self.doctype) > 1: if len(self.doctype) > 1:


+ 0
- 1
frappe/core/doctype/data_import/importer.py Просмотреть файл

@@ -1,7 +1,6 @@
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals
import os import os
import io import io
import frappe import frappe


+ 0
- 2
frappe/core/doctype/data_import/test_data_import.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2020, Frappe Technologies and Contributors # Copyright (c) 2020, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

# import frappe # import frappe
import unittest import unittest




+ 0
- 2
frappe/core/doctype/data_import/test_exporter.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies and Contributors # Copyright (c) 2019, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import unittest import unittest
import frappe import frappe
from frappe.core.doctype.data_import.exporter import Exporter from frappe.core.doctype.data_import.exporter import Exporter


+ 0
- 2
frappe/core/doctype/data_import/test_importer.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies and Contributors # Copyright (c) 2019, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import unittest import unittest
import frappe import frappe
from frappe.core.doctype.data_import.importer import Importer from frappe.core.doctype.data_import.importer import Importer


+ 2
- 6
frappe/core/doctype/data_import_legacy/importer.py Просмотреть файл

@@ -3,9 +3,6 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt


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
@@ -16,7 +13,6 @@ from frappe.utils.csvutils import getlink
from frappe.utils.dateutils import parse_date from frappe.utils.dateutils import parse_date


from frappe.utils import cint, cstr, flt, getdate, get_datetime, get_url, get_absolute_url, duration_to_seconds from frappe.utils import cint, cstr, flt, getdate, get_datetime, get_url, get_absolute_url, duration_to_seconds
from six import string_types




@frappe.whitelist() @frappe.whitelist()
@@ -42,7 +38,7 @@ def upload(rows = None, submit_after_import=None, ignore_encoding_errors=False,
frappe.cache().hdel("lang", user) frappe.cache().hdel("lang", user)
frappe.set_user_lang(user) frappe.set_user_lang(user)


if data_import_doc and isinstance(data_import_doc, string_types):
if data_import_doc and isinstance(data_import_doc, str):
data_import_doc = frappe.get_doc("Data Import Legacy", data_import_doc) data_import_doc = frappe.get_doc("Data Import Legacy", data_import_doc)
if data_import_doc and from_data_import == "Yes": if data_import_doc and from_data_import == "Yes":
no_email = data_import_doc.no_email no_email = data_import_doc.no_email
@@ -152,7 +148,7 @@ def upload(rows = None, submit_after_import=None, ignore_encoding_errors=False,
elif fieldtype in ("Float", "Currency", "Percent"): elif fieldtype in ("Float", "Currency", "Percent"):
d[fieldname] = flt(d[fieldname]) d[fieldname] = flt(d[fieldname])
elif fieldtype == "Date": elif fieldtype == "Date":
if d[fieldname] and isinstance(d[fieldname], string_types):
if d[fieldname] and isinstance(d[fieldname], str):
d[fieldname] = getdate(parse_date(d[fieldname])) d[fieldname] = getdate(parse_date(d[fieldname]))
elif fieldtype == "Datetime": elif fieldtype == "Datetime":
if d[fieldname]: if d[fieldname]:


+ 0
- 2
frappe/core/doctype/data_import_legacy/test_data_import_legacy.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2020, Frappe Technologies and Contributors # Copyright (c) 2020, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

# import frappe # import frappe
import unittest import unittest




+ 0
- 1
frappe/core/doctype/defaultvalue/__init__.py Просмотреть файл

@@ -1,4 +1,3 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals

+ 0
- 1
frappe/core/doctype/defaultvalue/defaultvalue.py Просмотреть файл

@@ -1,7 +1,6 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals
import frappe import frappe


from frappe.model.document import Document from frappe.model.document import Document


+ 0
- 1
frappe/core/doctype/deleted_document/deleted_document.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2015, Frappe Technologies and contributors # Copyright (c) 2015, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
import frappe import frappe
import json import json
from frappe.desk.doctype.bulk_update.bulk_update import show_progress from frappe.desk.doctype.bulk_update.bulk_update import show_progress


+ 0
- 2
frappe/core/doctype/deleted_document/test_deleted_document.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies and Contributors # Copyright (c) 2015, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import frappe import frappe
import unittest import unittest




+ 0
- 1
frappe/core/doctype/docfield/__init__.py Просмотреть файл

@@ -1,4 +1,3 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals

+ 0
- 2
frappe/core/doctype/docfield/docfield.py Просмотреть файл

@@ -1,8 +1,6 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals

import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document




+ 0
- 1
frappe/core/doctype/docperm/__init__.py Просмотреть файл

@@ -1,4 +1,3 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals

+ 0
- 1
frappe/core/doctype/docperm/docperm.py Просмотреть файл

@@ -1,7 +1,6 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals
import frappe import frappe


from frappe.model.document import Document from frappe.model.document import Document


+ 0
- 1
frappe/core/doctype/docshare/docshare.py Просмотреть файл

@@ -1,7 +1,6 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document
from frappe import _ from frappe import _


+ 0
- 1
frappe/core/doctype/docshare/test_docshare.py Просмотреть файл

@@ -1,7 +1,6 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt # See license.txt


from __future__ import unicode_literals
import frappe import frappe
import frappe.share import frappe.share
import unittest import unittest


+ 0
- 1
frappe/core/doctype/doctype/__init__.py Просмотреть файл

@@ -1,4 +1,3 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import unicode_literals

+ 2
- 7
frappe/core/doctype/doctype/doctype.py Просмотреть файл

@@ -2,15 +2,10 @@
# MIT License. See license.txt # MIT License. See license.txt


# imports - standard imports # imports - standard imports
from __future__ import unicode_literals
import re, copy, os, shutil import re, copy, os, shutil
import json import json
from frappe.cache_manager import clear_user_cache, clear_controller_cache from frappe.cache_manager import clear_user_cache, clear_controller_cache


# imports - third party imports
import six
from six import iteritems

# imports - module imports # imports - module imports
import frappe import frappe
import frappe.website.render import frappe.website.render
@@ -486,7 +481,7 @@ class DocType(Document):
# remove null and empty fields # remove null and empty fields
def remove_null_fields(o): def remove_null_fields(o):
to_remove = [] to_remove = []
for attr, value in iteritems(o):
for attr, value in o.items():
if isinstance(value, list): if isinstance(value, list):
for v in value: for v in value:
remove_null_fields(v) remove_null_fields(v)
@@ -670,7 +665,7 @@ class DocType(Document):
if not name: if not name:
name = self.name name = self.name


flags = {"flags": re.ASCII} if six.PY3 else {}
flags = {"flags": re.ASCII}


# a DocType name should not start or end with an empty space # a DocType name should not start or end with an empty space
if re.search(r"^[ \t\n\r]+|[ \t\n\r]+$", name, **flags): if re.search(r"^[ \t\n\r]+|[ \t\n\r]+$", name, **flags):


+ 0
- 2
frappe/core/doctype/doctype/test_doctype.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import frappe import frappe
import unittest import unittest
from frappe.core.doctype.doctype.doctype import (UniqueFieldnameError, from frappe.core.doctype.doctype.doctype import (UniqueFieldnameError,


+ 0
- 1
frappe/core/doctype/doctype_action/doctype_action.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2019, Frappe Technologies and contributors # Copyright (c) 2019, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
# import frappe # import frappe
from frappe.model.document import Document from frappe.model.document import Document




+ 0
- 1
frappe/core/doctype/doctype_link/doctype_link.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2019, Frappe Technologies and contributors # Copyright (c) 2019, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
# import frappe # import frappe
from frappe.model.document import Document from frappe.model.document import Document




+ 0
- 1
frappe/core/doctype/document_naming_rule/document_naming_rule.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2020, Frappe Technologies and contributors # Copyright (c) 2020, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document
from frappe.utils.data import evaluate_filters from frappe.utils.data import evaluate_filters


+ 0
- 2
frappe/core/doctype/document_naming_rule/test_document_naming_rule.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2020, Frappe Technologies and Contributors # Copyright (c) 2020, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import frappe import frappe
import unittest import unittest




+ 0
- 1
frappe/core/doctype/document_naming_rule_condition/document_naming_rule_condition.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2020, Frappe Technologies and contributors # Copyright (c) 2020, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
# import frappe # import frappe
from frappe.model.document import Document from frappe.model.document import Document




+ 0
- 2
frappe/core/doctype/document_naming_rule_condition/test_document_naming_rule_condition.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2020, Frappe Technologies and Contributors # Copyright (c) 2020, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

# import frappe # import frappe
import unittest import unittest




+ 0
- 1
frappe/core/doctype/domain/domain.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2017, Frappe Technologies and contributors # Copyright (c) 2017, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
import frappe import frappe


from frappe.model.document import Document from frappe.model.document import Document


+ 0
- 2
frappe/core/doctype/domain/test_domain.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2017, Frappe Technologies and Contributors # Copyright (c) 2017, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import frappe import frappe
import unittest import unittest




+ 0
- 1
frappe/core/doctype/domain_settings/domain_settings.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2017, Frappe Technologies and contributors # Copyright (c) 2017, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document




+ 0
- 1
frappe/core/doctype/dynamic_link/dynamic_link.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2015, Frappe Technologies and contributors # Copyright (c) 2015, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document




+ 0
- 1
frappe/core/doctype/error_log/error_log.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2015, Frappe Technologies and contributors # Copyright (c) 2015, Frappe Technologies and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document




+ 0
- 2
frappe/core/doctype/error_log/test_error_log.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies and Contributors # Copyright (c) 2015, Frappe Technologies and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import frappe import frappe
import unittest import unittest




+ 0
- 1
frappe/core/doctype/error_snapshot/error_snapshot.py Просмотреть файл

@@ -2,7 +2,6 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt # For license information, please see license.txt


from __future__ import unicode_literals
import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document




+ 0
- 2
frappe/core/doctype/error_snapshot/test_error_snapshot.py Просмотреть файл

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt # See license.txt
from __future__ import unicode_literals

import frappe import frappe
import unittest import unittest




+ 18
- 24
frappe/core/doctype/file/file.py Просмотреть файл

@@ -7,8 +7,6 @@ record of files
naming for same name files: file.gif, file-1.gif, file-2.gif etc naming for same name files: file.gif, file-1.gif, file-2.gif etc
""" """


from __future__ import unicode_literals

import base64 import base64
import hashlib import hashlib
import imghdr import imghdr
@@ -23,8 +21,8 @@ import zipfile
import requests import requests
import requests.exceptions import requests.exceptions
from PIL import Image, ImageFile, ImageOps from PIL import Image, ImageFile, ImageOps
from six import PY2, StringIO, string_types, text_type
from six.moves.urllib.parse import quote, unquote
from io import StringIO
from urllib.parse import quote, unquote


import frappe import frappe
from frappe import _, conf from frappe import _, conf
@@ -382,18 +380,14 @@ class File(Document):
file_path = self.get_full_path() file_path = self.get_full_path()


# read the file # read the file
if PY2:
with open(encode(file_path)) as f:
content = f.read()
else:
with io.open(encode(file_path), mode='rb') as f:
content = f.read()
try:
# for plain text files
content = content.decode()
except UnicodeDecodeError:
# for .png, .jpg, etc
pass
with io.open(encode(file_path), mode='rb') as f:
content = f.read()
try:
# for plain text files
content = content.decode()
except UnicodeDecodeError:
# for .png, .jpg, etc
pass


return content return content


@@ -430,7 +424,7 @@ class File(Document):
frappe.create_folder(file_path) frappe.create_folder(file_path)
# write the file # write the file
self.content = self.get_content() self.content = self.get_content()
if isinstance(self.content, text_type):
if isinstance(self.content, str):
self.content = self.content.encode() self.content = self.content.encode()
with open(os.path.join(file_path.encode('utf-8'), self.file_name.encode('utf-8')), 'wb+') as f: with open(os.path.join(file_path.encode('utf-8'), self.file_name.encode('utf-8')), 'wb+') as f:
f.write(self.content) f.write(self.content)
@@ -483,7 +477,7 @@ class File(Document):
self.content = content self.content = content


if decode: if decode:
if isinstance(content, text_type):
if isinstance(content, str):
self.content = content.encode("utf-8") self.content = content.encode("utf-8")


if b"," in self.content: if b"," in self.content:
@@ -632,7 +626,7 @@ def create_new_folder(file_name, folder):
@frappe.whitelist() @frappe.whitelist()
def move_file(file_list, new_parent, old_parent): def move_file(file_list, new_parent, old_parent):


if isinstance(file_list, string_types):
if isinstance(file_list, str):
file_list = json.loads(file_list) file_list = json.loads(file_list)


for file_obj in file_list: for file_obj in file_list:
@@ -834,7 +828,7 @@ def remove_file_by_url(file_url, doctype=None, name=None):




def get_content_hash(content): def get_content_hash(content):
if isinstance(content, text_type):
if isinstance(content, str):
content = content.encode() content = content.encode()
return hashlib.md5(content).hexdigest() #nosec return hashlib.md5(content).hexdigest() #nosec


@@ -887,8 +881,8 @@ def extract_images_from_html(doc, content):
filename = headers.split("filename=")[-1] filename = headers.split("filename=")[-1]


# decode filename # decode filename
if not isinstance(filename, text_type):
filename = text_type(filename, 'utf-8')
if not isinstance(filename, str):
filename = str(filename, 'utf-8')
else: else:
mtype = headers.split(";")[0] mtype = headers.split(";")[0]
filename = get_random_filename(content_type=mtype) filename = get_random_filename(content_type=mtype)
@@ -911,7 +905,7 @@ def extract_images_from_html(doc, content):


return '<img src="{file_url}"'.format(file_url=file_url) return '<img src="{file_url}"'.format(file_url=file_url)


if content and isinstance(content, string_types):
if content and isinstance(content, str):
content = re.sub(r'<img[^>]*src\s*=\s*["\'](?=data:)(.*?)["\']', _save_file, content) content = re.sub(r'<img[^>]*src\s*=\s*["\'](?=data:)(.*?)["\']', _save_file, content)


return content return content
@@ -941,7 +935,7 @@ def get_attached_images(doctype, names):
'''get list of image urls attached in form '''get list of image urls attached in form
returns {name: ['image.jpg', 'image.png']}''' returns {name: ['image.jpg', 'image.png']}'''


if isinstance(names, string_types):
if isinstance(names, str):
names = json.loads(names) names = json.loads(names)


img_urls = frappe.db.get_list('File', filters={ img_urls = frappe.db.get_list('File', filters={


Некоторые файлы не были показаны из-за большого количества измененных файлов

Загрузка…
Отмена
Сохранить