fix: remove six imports and use py3 defaults
This commit is contained in:
parent
72fbcac70c
commit
c4a9238549
1 changed files with 5 additions and 6 deletions
|
|
@ -18,8 +18,7 @@ from email.utils import formataddr, parseaddr
|
|||
from gzip import GzipFile
|
||||
from typing import Generator, Iterable
|
||||
|
||||
from six import string_types, text_type
|
||||
from six.moves.urllib.parse import quote, urlparse
|
||||
from urllib.parse import quote, urlparse
|
||||
from werkzeug.test import Client
|
||||
|
||||
import frappe
|
||||
|
|
@ -72,7 +71,7 @@ def get_formatted_email(user, mail=None):
|
|||
def extract_email_id(email):
|
||||
"""fetch only the email part of the Email Address"""
|
||||
email_id = parse_addr(email)[1]
|
||||
if email_id and isinstance(email_id, string_types) and not isinstance(email_id, text_type):
|
||||
if email_id and isinstance(email_id, str) and not isinstance(email_id, str):
|
||||
email_id = email_id.decode("utf-8", "ignore")
|
||||
return email_id
|
||||
|
||||
|
|
@ -370,14 +369,14 @@ def get_site_url(site):
|
|||
|
||||
def encode_dict(d, encoding="utf-8"):
|
||||
for key in d:
|
||||
if isinstance(d[key], string_types) and isinstance(d[key], text_type):
|
||||
if isinstance(d[key], str) and isinstance(d[key], str):
|
||||
d[key] = d[key].encode(encoding)
|
||||
|
||||
return d
|
||||
|
||||
def decode_dict(d, encoding="utf-8"):
|
||||
for key in d:
|
||||
if isinstance(d[key], string_types) and not isinstance(d[key], text_type):
|
||||
if isinstance(d[key], str) and not isinstance(d[key], str):
|
||||
d[key] = d[key].decode(encoding, "ignore")
|
||||
|
||||
return d
|
||||
|
|
@ -644,7 +643,7 @@ def parse_json(val):
|
|||
"""
|
||||
Parses json if string else return
|
||||
"""
|
||||
if isinstance(val, string_types):
|
||||
if isinstance(val, str):
|
||||
val = json.loads(val)
|
||||
if isinstance(val, dict):
|
||||
val = frappe._dict(val)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue