From 35eaba1096f9d7a606cda92824e57f9791be183b Mon Sep 17 00:00:00 2001 From: mdipierro Date: Mon, 1 Aug 2016 03:39:22 -0500 Subject: [PATCH] removed duplicated code, using pydal's _compat.py --- gluon/_compat.py | 172 -------------------------- gluon/admin.py | 2 +- gluon/cache.py | 2 +- gluon/compileapp.py | 2 +- gluon/contenttype.py | 2 +- gluon/contrib/appconfig.py | 2 +- gluon/contrib/autolinks.py | 2 +- gluon/contrib/markmin/markmin2html.py | 2 +- gluon/contrib/shell.py | 2 +- gluon/contrib/webclient.py | 2 +- gluon/custom_import.py | 2 +- gluon/debug.py | 2 +- gluon/fileutils.py | 2 +- gluon/globals.py | 4 +- gluon/highlight.py | 13 +- gluon/html.py | 6 +- gluon/http.py | 2 +- gluon/languages.py | 7 +- gluon/local_html_escape.py | 27 ++++ gluon/main.py | 2 +- gluon/packages/dal | 2 +- gluon/recfile.py | 2 +- gluon/restricted.py | 2 +- gluon/rewrite.py | 2 +- gluon/rocket.py | 2 +- gluon/scheduler.py | 2 +- gluon/serializers.py | 2 +- gluon/settings.py | 2 +- gluon/shell.py | 2 +- gluon/sqlhtml.py | 2 +- gluon/storage.py | 2 +- gluon/streamer.py | 2 +- gluon/template.py | 2 +- gluon/tests/test_contenttype.py | 2 +- gluon/tests/test_contribs.py | 2 +- gluon/tests/test_dal.py | 2 +- gluon/tests/test_globals.py | 2 +- gluon/tests/test_html.py | 2 +- gluon/tests/test_languages.py | 2 +- gluon/tests/test_router.py | 2 +- gluon/tests/test_routes.py | 2 +- gluon/tests/test_storage.py | 2 +- gluon/tests/test_template.py | 2 +- gluon/tests/test_tools.py | 2 +- gluon/tests/test_validators.py | 2 +- gluon/tests/test_web.py | 2 +- gluon/tools.py | 2 +- gluon/utf8.py | 2 +- gluon/utils.py | 2 +- gluon/validators.py | 2 +- gluon/widget.py | 2 +- 51 files changed, 87 insertions(+), 232 deletions(-) delete mode 100644 gluon/_compat.py create mode 100644 gluon/local_html_escape.py diff --git a/gluon/_compat.py b/gluon/_compat.py deleted file mode 100644 index 1c3421c5..00000000 --- a/gluon/_compat.py +++ /dev/null @@ -1,172 +0,0 @@ -import sys -import hashlib -import os - -PY2 = sys.version_info[0] == 2 - -_identity = lambda x: x - -if PY2: - import cPickle as pickle - from cStringIO import StringIO - import copy_reg as copyreg - from HTMLParser import HTMLParser - import urlparse - from htmlentitydefs import entitydefs, name2codepoint - import __builtin__ as builtin - import thread - import Cookie - import urllib2 - import Queue - import ConfigParser as configparser - from email.MIMEBase import MIMEBase - from email.Header import Header - from email import Encoders, Charset - from email.MIMEMultipart import MIMEMultipart - from email.MIMEText import MIMEText - from email.Charset import add_charset, QP as charset_QP - from urllib import FancyURLopener, urlencode, urlopen - from urllib import quote as urllib_quote, unquote as urllib_unquote - from string import maketrans - from types import ClassType - import cgi - import cookielib - reduce = reduce - hashlib_md5 = hashlib.md5 - iterkeys = lambda d: d.iterkeys() - itervalues = lambda d: d.itervalues() - iteritems = lambda d: d.iteritems() - integer_types = (int, long) - string_types = (str, unicode) - text_type = unicode - basestring = basestring - xrange = xrange - long = long - unichr = unichr - unicodeT = unicode - - def implements_bool(cls): - cls.__nonzero__ = cls.__bool__ - del cls.__bool__ - return cls - - def to_bytes(obj, charset='utf-8', errors='strict'): - if obj is None: - return None - if isinstance(obj, (bytes, bytearray, buffer)): - return bytes(obj) - if isinstance(obj, unicode): - return obj.encode(charset, errors) - raise TypeError('Expected bytes') - - def to_native(obj, charset='utf8', errors='strict'): - if obj is None or isinstance(obj, str): - return obj - return obj.encode(charset, errors) - - def _local_html_escape(data, quote=False): - s = cgi.escape(data, quote) - return s.replace("'", "'") if quote else s - -else: - import pickle - from io import StringIO - import copyreg - from functools import reduce - from html.parser import HTMLParser - from http import cookies as Cookie - from urllib import parse as urlparse - from urllib import request as urllib2 - from html.entities import entitydefs, name2codepoint - import builtins as builtin - import _thread as thread - import configparser - import queue as Queue - from email.mime.base import MIMEBase - from email.mime.multipart import MIMEMultipart - from email.mime.text import MIMEText - from email import encoders as Encoders - from email.header import Header - from email.charset import Charset, add_charset, QP as charset_QP - from urllib.request import FancyURLopener, urlopen - from urllib.parse import quote as urllib_quote, unquote as urllib_unquote, urlencode - from http import cookiejar as cookielib - import html - hashlib_md5 = lambda s: hashlib.md5(bytes(s, 'utf8')) - iterkeys = lambda d: iter(d.keys()) - itervalues = lambda d: iter(d.values()) - iteritems = lambda d: iter(d.items()) - integer_types = (int,) - string_types = (str,) - text_type = str - basestring = str - xrange = range - long = int - unichr = chr - unicodeT = str - maketrans = str.maketrans - ClassType = type - - implements_iterator = _identity - implements_bool = _identity - - def to_bytes(obj, charset='utf-8', errors='strict'): - if obj is None: - return None - if isinstance(obj, (bytes, bytearray, memoryview)): - return bytes(obj) - if isinstance(obj, str): - return obj.encode(charset, errors) - raise TypeError('Expected bytes') - - def to_native(obj, charset='utf8', errors='strict'): - if obj is None or isinstance(obj, str): - return obj - return obj.decode(charset, errors) - - def _local_html_escape(s, quote=True): - """ - Works with bytes. - Replace special characters "&", "<" and ">" to HTML-safe sequences. - If the optional flag quote is true (the default), the quotation mark - characters, both double quote (") and single quote (') characters are also - translated. - """ - if isinstance(s, str): - return html.escape(s, quote=quote) - - s = s.replace(b"&", b"&") # Must be done first! - s = s.replace(b"<", b"<") - s = s.replace(b">", b">") - if quote: - s = s.replace(b'"', b""") - s = s.replace(b'\'', b"'") - return s - -def with_metaclass(meta, *bases): - """Create a base class with a metaclass.""" - # This requires a bit of explanation: the basic idea is to make a dummy - # metaclass for one level of class instantiation that replaces itself with - # the actual metaclass. - class metaclass(meta): - __call__ = type.__call__ - __init__ = type.__init__ - - def __new__(cls, name, this_bases, d): - if this_bases is None: - return type.__new__(cls, name, (), d) - return meta(name, bases, d) - return metaclass('temporary_class', None, {}) - - -def to_unicode(obj, charset='utf-8', errors='strict'): - if obj is None: - return None - if not isinstance(obj, bytes): - return text_type(obj) - return obj.decode(charset, errors) - - -# shortcuts -pjoin = os.path.join -exists = os.path.exists diff --git a/gluon/admin.py b/gluon/admin.py index 8c70c348..9a1a5ff8 100644 --- a/gluon/admin.py +++ b/gluon/admin.py @@ -22,7 +22,7 @@ from gluon.fileutils import read_file, write_file, parse_version from gluon.restricted import RestrictedError from gluon.settings import global_settings from gluon.cache import CacheOnDisk -from gluon._compat import urlopen, to_native +from pydal._compat import urlopen, to_native if not global_settings.web2py_runtime_gae: import site diff --git a/gluon/cache.py b/gluon/cache.py index 474910bb..8407ab15 100644 --- a/gluon/cache.py +++ b/gluon/cache.py @@ -40,7 +40,7 @@ try: except ImportError: have_settings = False -from gluon._compat import pickle, thread, to_bytes, to_native, hashlib_md5 +from pydal._compat import pickle, thread, to_bytes, to_native, hashlib_md5 try: import psutil diff --git a/gluon/compileapp.py b/gluon/compileapp.py index 0ee9c18c..5d0dc3b6 100644 --- a/gluon/compileapp.py +++ b/gluon/compileapp.py @@ -18,7 +18,7 @@ import fnmatch import os import copy import random -from gluon._compat import builtin, PY2, unicodeT, to_native, to_bytes, iteritems, basestring, reduce, xrange, long +from pydal._compat import builtin, PY2, unicodeT, to_native, to_bytes, iteritems, basestring, reduce, xrange, long from gluon.storage import Storage, List from gluon.template import parse_template from gluon.restricted import restricted, compile2 diff --git a/gluon/contenttype.py b/gluon/contenttype.py index 7dd28f35..146ee2f4 100644 --- a/gluon/contenttype.py +++ b/gluon/contenttype.py @@ -19,7 +19,7 @@ Additions: - .pickle: application/python-pickle - .w2p': application/w2p """ -from gluon._compat import to_native +from pydal._compat import to_native __all__ = ['contenttype'] diff --git a/gluon/contrib/appconfig.py b/gluon/contrib/appconfig.py index 1160e08a..849ada00 100644 --- a/gluon/contrib/appconfig.py +++ b/gluon/contrib/appconfig.py @@ -29,7 +29,7 @@ is restarted (or reload=True is passed). """ import os import json -from gluon._compat import thread, configparser +from pydal._compat import thread, configparser from gluon.globals import current locker = thread.allocate_lock() diff --git a/gluon/contrib/autolinks.py b/gluon/contrib/autolinks.py index 4670c304..91d53a96 100644 --- a/gluon/contrib/autolinks.py +++ b/gluon/contrib/autolinks.py @@ -42,7 +42,7 @@ revision3.com viddler.com """ from __future__ import print_function -from gluon._compat import FancyURLopener, urllib_quote +from pydal._compat import FancyURLopener, urllib_quote import re import cgi diff --git a/gluon/contrib/markmin/markmin2html.py b/gluon/contrib/markmin/markmin2html.py index fe9b374d..ff092bac 100755 --- a/gluon/contrib/markmin/markmin2html.py +++ b/gluon/contrib/markmin/markmin2html.py @@ -6,7 +6,7 @@ from __future__ import print_function import re import urllib -from gluon._compat import maketrans, urllib_quote, unicodeT, _local_html_escape, to_bytes, to_native, _local_html_escape as escape, xrange +from pydal._compat import maketrans, urllib_quote, unicodeT, _local_html_escape, to_bytes, to_native, _local_html_escape as escape, xrange from ast import parse as ast_parse import ast diff --git a/gluon/contrib/shell.py b/gluon/contrib/shell.py index 638d3c81..6f43465a 100755 --- a/gluon/contrib/shell.py +++ b/gluon/contrib/shell.py @@ -29,7 +29,7 @@ An interactive, stateful AJAX shell that runs Python code on the server. """ from __future__ import print_function -from gluon._compat import ClassType, pickle, StringIO +from pydal._compat import ClassType, pickle, StringIO import logging import new import sys diff --git a/gluon/contrib/webclient.py b/gluon/contrib/webclient.py index c5e7f3c7..670e93d1 100644 --- a/gluon/contrib/webclient.py +++ b/gluon/contrib/webclient.py @@ -16,7 +16,7 @@ mostly for testing purposes Some examples at the bottom. """ from __future__ import print_function -from gluon._compat import urllib2, cookielib, iteritems, to_native, urlencode, to_bytes +from pydal._compat import urllib2, cookielib, iteritems, to_native, urlencode, to_bytes import re import time diff --git a/gluon/custom_import.py b/gluon/custom_import.py index ef6c7ab2..1840561c 100644 --- a/gluon/custom_import.py +++ b/gluon/custom_import.py @@ -8,7 +8,7 @@ Support for smart import syntax for web2py applications ------------------------------------------------------- """ -from gluon._compat import builtin, unicodeT, PY2, to_native +from pydal._compat import builtin, unicodeT, PY2, to_native import os import sys import threading diff --git a/gluon/debug.py b/gluon/debug.py index a4432590..dd89836e 100644 --- a/gluon/debug.py +++ b/gluon/debug.py @@ -14,7 +14,7 @@ Debugger support classes import logging import pdb import sys -from gluon._compat import Queue +from pydal._compat import Queue logger = logging.getLogger("web2py") diff --git a/gluon/fileutils.py b/gluon/fileutils.py index 27fe8a8d..07624dc4 100644 --- a/gluon/fileutils.py +++ b/gluon/fileutils.py @@ -21,7 +21,7 @@ import logging from gluon.http import HTTP from gzip import open as gzopen from gluon.recfile import generate -from gluon._compat import PY2 +from pydal._compat import PY2 __all__ = [ 'parse_version', diff --git a/gluon/globals.py b/gluon/globals.py index b1a501e3..62ce0764 100644 --- a/gluon/globals.py +++ b/gluon/globals.py @@ -13,7 +13,7 @@ Contains the classes for the global used variables: - Session """ -from gluon._compat import pickle, StringIO, copyreg, Cookie, urlparse, PY2, iteritems, to_unicode, to_native, unicodeT +from pydal._compat import pickle, StringIO, copyreg, Cookie, urlparse, PY2, iteritems, to_unicode, to_native, unicodeT from gluon.storage import Storage, List from gluon.streamer import streamer, stream_file_or_304_or_206, DEFAULT_CHUNK_SIZE from gluon.contenttype import contenttype @@ -436,7 +436,7 @@ class Response(Storage): self._vars.update(b) self._view_environment.update(self._vars) if view: - from gluon._compat import StringIO + from pydal._compat import StringIO (obody, oview) = (self.body, self.view) (self.body, self.view) = (StringIO(), view) run_view_in(self._view_environment) diff --git a/gluon/highlight.py b/gluon/highlight.py index 56afc2ea..c0b823b5 100644 --- a/gluon/highlight.py +++ b/gluon/highlight.py @@ -7,7 +7,8 @@ | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html) """ from __future__ import print_function -from gluon._compat import xrange, _local_html_escape +from pydal._compat import xrange, +from local_html_escape import local_html_escape import re __all__ = ['highlight'] @@ -62,7 +63,7 @@ class Highlighter(object): Callback for C specific highlighting. """ - value = _local_html_escape(match.group(), quote=False) + value = local_html_escape(match.group(), quote=False) self.change_style(token, style) self.output.append(value) @@ -76,7 +77,7 @@ class Highlighter(object): Callback for python specific highlighting. """ - value = _local_html_escape(match.group(), quote=False) + value = local_html_escape(match.group(), quote=False) if token == 'MULTILINESTRING': self.change_style(token, style) self.output.append(value) @@ -113,7 +114,7 @@ class Highlighter(object): Callback for HTML specific highlighting. """ - value = _local_html_escape(match.group(), quote=False) + value = local_html_escape(match.group(), quote=False) self.change_style(token, style) self.output.append(value) if token == 'GOTOPYTHON': @@ -291,13 +292,13 @@ def highlight( 'WEB2PY']: code = Highlighter(language, link, styles).highlight(code) else: - code = _local_html_escape(code, quote=False) + code = local_html_escape(code, quote=False) lines = code.split('\n') if counter is None: linenumbers = [''] * len(lines) elif isinstance(counter, str): - linenumbers = [_local_html_escape(counter, quote=False)] * len(lines) + linenumbers = [local_html_escape(counter, quote=False)] * len(lines) else: linenumbers = [str(i + counter) + '.' for i in xrange(len(lines))] diff --git a/gluon/html.py b/gluon/html.py index 11f9653e..f8fe625c 100644 --- a/gluon/html.py +++ b/gluon/html.py @@ -20,8 +20,8 @@ import urllib import base64 from gluon import sanitizer, decoder import itertools -from gluon._compat import reduce, pickle, copyreg, HTMLParser, name2codepoint, iteritems, unichr, unicodeT, urllib_quote, to_bytes, \ - to_native, to_unicode, _local_html_escape, basestring, urlencode, implements_bool +from pydal._compat import reduce, pickle, copyreg, HTMLParser, name2codepoint, iteritems, unichr, unicodeT, urllib_quote, to_bytes, to_native, to_unicode, basestring, urlencode, implements_bool +from local_html_escape import local_html_escape import marshal from gluon.storage import Storage @@ -129,7 +129,7 @@ def xmlescape(data, quote=True): # ... and do the escaping - data = _local_html_escape(data, quote) + data = local_html_escape(data, quote) return data diff --git a/gluon/http.py b/gluon/http.py index e34fb8f0..9cf17eec 100644 --- a/gluon/http.py +++ b/gluon/http.py @@ -11,7 +11,7 @@ HTTP statuses helpers """ import re -from gluon._compat import iteritems +from pydal._compat import iteritems __all__ = ['HTTP', 'redirect'] diff --git a/gluon/languages.py b/gluon/languages.py index 6b4748d8..cd60e352 100644 --- a/gluon/languages.py +++ b/gluon/languages.py @@ -18,9 +18,8 @@ import pkgutil import logging from cgi import escape from threading import RLock -from gluon._compat import copyreg, PY2, maketrans, iterkeys, unicodeT, to_unicode, to_bytes, iteritems, _local_html_escape, to_native, \ - pjoin - +from pydal._compat import copyreg, PY2, maketrans, iterkeys, unicodeT, to_unicode, to_bytes, iteritems, to_native, pjoin +from local_html_escape import local_html_escape from gluon.portalocker import read_locked, LockedFile from gluon.utf8 import Utf8 @@ -423,7 +422,7 @@ class lazyT(object): return len(str(self)) def xml(self): - return str(self) if self.M else _local_html_escape(str(self), quote=False) + return str(self) if self.M else local_html_escape(str(self), quote=False) def encode(self, *a, **b): return str(self).encode(*a, **b) diff --git a/gluon/local_html_escape.py b/gluon/local_html_escape.py new file mode 100644 index 00000000..a4345eef --- /dev/null +++ b/gluon/local_html_escape.py @@ -0,0 +1,27 @@ +import sys + +PY2 = sys.version_info[0] == 2 + +def local_html_escape(data, quote=False): + """ + Works with bytes. + Replace special characters "&", "<" and ">" to HTML-safe sequences. + If the optional flag quote is true (the default), the quotation mark + characters, both double quote (") and single quote (') characters are also + translated. + """ + if PY2: + import cgi + s = cgi.escape(data, quote) + return s.replace("'", "'") if quote else s + else: + import html + if isinstance(s, str): + return html.escape(s, quote=quote) + s = s.replace(b"&", b"&") # Must be done first! + s = s.replace(b"<", b"<") + s = s.replace(b">", b">") + if quote: + s = s.replace(b'"', b""") + s = s.replace(b'\'', b"'") + return s diff --git a/gluon/main.py b/gluon/main.py index 971c48a7..1549b3df 100644 --- a/gluon/main.py +++ b/gluon/main.py @@ -25,7 +25,7 @@ import socket import random import string -from gluon._compat import Cookie, urllib2 +from pydal._compat import Cookie, urllib2 #from thread import allocate_lock from gluon.fileutils import abspath, write_file diff --git a/gluon/packages/dal b/gluon/packages/dal index 9a5332e4..79ec4e99 160000 --- a/gluon/packages/dal +++ b/gluon/packages/dal @@ -1 +1 @@ -Subproject commit 9a5332e45bef6516bf159b69e2cd0b355ec9a6ca +Subproject commit 79ec4e99d09b768ca2dcc42ac32f408529e0745f diff --git a/gluon/recfile.py b/gluon/recfile.py index 51f81cf9..9881e7ac 100755 --- a/gluon/recfile.py +++ b/gluon/recfile.py @@ -10,7 +10,7 @@ Generates names for cache and session files -------------------------------------------- """ import os -from gluon._compat import builtin +from pydal._compat import builtin def generate(filename, depth=2, base=512): if os.path.sep in filename: diff --git a/gluon/restricted.py b/gluon/restricted.py index c67bcbf4..6f4493b2 100644 --- a/gluon/restricted.py +++ b/gluon/restricted.py @@ -10,7 +10,7 @@ Restricted environment to execute application's code """ import sys -from gluon._compat import pickle, ClassType +from pydal._compat import pickle, ClassType import traceback import types import os diff --git a/gluon/rewrite.py b/gluon/rewrite.py index fc14557a..bced6731 100644 --- a/gluon/rewrite.py +++ b/gluon/rewrite.py @@ -27,7 +27,7 @@ from gluon.storage import Storage, List from gluon.http import HTTP from gluon.fileutils import abspath, read_file from gluon.settings import global_settings -from gluon._compat import urllib_unquote, urllib_quote, iteritems, xrange +from pydal._compat import urllib_unquote, urllib_quote, iteritems, xrange isdir = os.path.isdir isfile = os.path.isfile diff --git a/gluon/rocket.py b/gluon/rocket.py index c41ac32d..c3eb5006 100644 --- a/gluon/rocket.py +++ b/gluon/rocket.py @@ -11,7 +11,7 @@ import errno import socket import logging import platform -from gluon._compat import iteritems, to_bytes, StringIO, urllib_unquote +from pydal._compat import iteritems, to_bytes, StringIO, urllib_unquote # Define Constants VERSION = '1.2.6' diff --git a/gluon/scheduler.py b/gluon/scheduler.py index 1b9a478e..cc429591 100644 --- a/gluon/scheduler.py +++ b/gluon/scheduler.py @@ -29,7 +29,7 @@ from json import loads, dumps from gluon import DAL, Field, IS_NOT_EMPTY, IS_IN_SET, IS_NOT_IN_DB, IS_EMPTY_OR from gluon import IS_INT_IN_RANGE, IS_DATETIME, IS_IN_DB from gluon.utils import web2py_uuid -from gluon._compat import Queue, long, iteritems +from pydal._compat import Queue, long, iteritems from gluon.storage import Storage USAGE = """ diff --git a/gluon/serializers.py b/gluon/serializers.py index d53740d7..823c5b2b 100644 --- a/gluon/serializers.py +++ b/gluon/serializers.py @@ -10,7 +10,7 @@ from gluon.html import TAG, XmlComponent, xmlescape from gluon.languages import lazyT import gluon.contrib.rss2 as rss2 import json as json_parser -from gluon._compat import long, to_native, unicodeT +from pydal._compat import long, to_native, unicodeT have_yaml = True try: diff --git a/gluon/settings.py b/gluon/settings.py index 5e2af7e0..1ef8fcad 100644 --- a/gluon/settings.py +++ b/gluon/settings.py @@ -10,7 +10,7 @@ import os import sys import platform from gluon.storage import Storage -from gluon._compat import PY2 +from pydal._compat import PY2 global_settings = Storage() settings = global_settings # legacy compatibility diff --git a/gluon/shell.py b/gluon/shell.py index 95359c3a..29462491 100644 --- a/gluon/shell.py +++ b/gluon/shell.py @@ -30,7 +30,7 @@ from gluon.globals import Request, Response, Session from gluon.storage import Storage, List from gluon.admin import w2p_unpack from pydal.base import BaseAdapter -from gluon._compat import iteritems, ClassType +from pydal._compat import iteritems, ClassType logger = logging.getLogger("web2py") diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index 9ddc34d6..3e8d8843 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -19,7 +19,7 @@ import urllib import re import os -from gluon._compat import StringIO, unichr, urllib_quote, iteritems, basestring, long, unicodeT, to_native +from pydal._compat import StringIO, unichr, urllib_quote, iteritems, basestring, long, unicodeT, to_native from gluon.http import HTTP, redirect from gluon.html import XmlComponent, truncate_string from gluon.html import XML, SPAN, TAG, A, DIV, CAT, UL, LI, TEXTAREA, BR, IMG diff --git a/gluon/storage.py b/gluon/storage.py index 2d8c3dfa..4bb12b5b 100644 --- a/gluon/storage.py +++ b/gluon/storage.py @@ -12,7 +12,7 @@ Provides: - Storage; like dictionary allowing also for `obj.foo` for `obj['foo']` """ -from gluon._compat import copyreg, pickle, PY2 +from pydal._compat import copyreg, pickle, PY2 import gluon.portalocker as portalocker __all__ = ['List', 'Storage', 'Settings', 'Messages', diff --git a/gluon/streamer.py b/gluon/streamer.py index dd7b78b2..c10c129c 100644 --- a/gluon/streamer.py +++ b/gluon/streamer.py @@ -17,7 +17,7 @@ import re import errno from gluon.http import HTTP from gluon.contenttype import contenttype -from gluon._compat import PY2 +from pydal._compat import PY2 regex_start_range = re.compile('\d+(?=\-)') diff --git a/gluon/template.py b/gluon/template.py index 2afc29ab..5ce69655 100644 --- a/gluon/template.py +++ b/gluon/template.py @@ -18,7 +18,7 @@ import os import cgi import logging from re import compile, sub, escape, DOTALL -from gluon._compat import StringIO, unicodeT, to_unicode, to_bytes, to_native +from pydal._compat import StringIO, unicodeT, to_unicode, to_bytes, to_native try: # have web2py diff --git a/gluon/tests/test_contenttype.py b/gluon/tests/test_contenttype.py index 1a476a62..ba73fd42 100644 --- a/gluon/tests/test_contenttype.py +++ b/gluon/tests/test_contenttype.py @@ -11,7 +11,7 @@ from .fix_path import fix_sys_path fix_sys_path(__file__) from gluon.contenttype import contenttype -from gluon._compat import iteritems +from pydal._compat import iteritems class TestContentType(unittest.TestCase): diff --git a/gluon/tests/test_contribs.py b/gluon/tests/test_contribs.py index 577056e4..012f1648 100644 --- a/gluon/tests/test_contribs.py +++ b/gluon/tests/test_contribs.py @@ -8,7 +8,7 @@ import os from .fix_path import fix_sys_path fix_sys_path(__file__) -from gluon._compat import to_bytes +from pydal._compat import to_bytes from gluon.storage import Storage from gluon.contrib import fpdf as fpdf from gluon.contrib import pyfpdf as pyfpdf diff --git a/gluon/tests/test_dal.py b/gluon/tests/test_dal.py index 4c7e0b24..fe574a8a 100644 --- a/gluon/tests/test_dal.py +++ b/gluon/tests/test_dal.py @@ -34,7 +34,7 @@ class TestDALSubclass(unittest.TestCase): db.close() def testSerialization(self): - from gluon._compat import pickle + from pydal._compat import pickle db = DAL(check_reserved=['all']) db.define_table('t_a', Field('f_a')) db.t_a.insert(f_a='test') diff --git a/gluon/tests/test_globals.py b/gluon/tests/test_globals.py index d2336093..4ef0aa10 100644 --- a/gluon/tests/test_globals.py +++ b/gluon/tests/test_globals.py @@ -14,7 +14,7 @@ fix_sys_path(__file__) from gluon.globals import Request, Response, Session from gluon import URL -from gluon._compat import basestring +from pydal._compat import basestring def setup_clean_session(): request = Request(env={}) diff --git a/gluon/tests/test_html.py b/gluon/tests/test_html.py index 9b98f2c2..18bc80f3 100644 --- a/gluon/tests/test_html.py +++ b/gluon/tests/test_html.py @@ -17,7 +17,7 @@ from gluon.html import STYLE, TABLE, TR, TD, TAG, TBODY, THEAD, TEXTAREA, TFOOT, from gluon.storage import Storage from gluon.html import XML_pickle, XML_unpickle from gluon.html import TAG_pickler, TAG_unpickler -from gluon._compat import xrange, PY2, to_native +from pydal._compat import xrange, PY2, to_native class TestBareHelpers(unittest.TestCase): diff --git a/gluon/tests/test_languages.py b/gluon/tests/test_languages.py index acc621ea..90fd3932 100644 --- a/gluon/tests/test_languages.py +++ b/gluon/tests/test_languages.py @@ -15,7 +15,7 @@ from .fix_path import fix_sys_path fix_sys_path(__file__) from gluon import languages -from gluon._compat import PY2 +from pydal._compat import PY2 MP_WORKING = 0 try: diff --git a/gluon/tests/test_router.py b/gluon/tests/test_router.py index edec86cd..c42881f2 100644 --- a/gluon/tests/test_router.py +++ b/gluon/tests/test_router.py @@ -21,7 +21,7 @@ from gluon.fileutils import abspath from gluon.settings import global_settings from gluon.http import HTTP from gluon.storage import Storage -from gluon._compat import to_bytes, to_native, PY2 +from pydal._compat import to_bytes, to_native, PY2 logger = None oldcwd = None diff --git a/gluon/tests/test_routes.py b/gluon/tests/test_routes.py index 16bb8a09..1d2113f4 100644 --- a/gluon/tests/test_routes.py +++ b/gluon/tests/test_routes.py @@ -21,7 +21,7 @@ from gluon.fileutils import abspath from gluon.settings import global_settings from gluon.http import HTTP from gluon.storage import Storage -from gluon._compat import to_bytes +from pydal._compat import to_bytes logger = None oldcwd = None diff --git a/gluon/tests/test_storage.py b/gluon/tests/test_storage.py index 48adce2e..7acae127 100644 --- a/gluon/tests/test_storage.py +++ b/gluon/tests/test_storage.py @@ -10,7 +10,7 @@ fix_sys_path(__file__) from gluon.storage import Storage, StorageList, List from gluon.http import HTTP -from gluon._compat import pickle +from pydal._compat import pickle class TestStorage(unittest.TestCase): diff --git a/gluon/tests/test_template.py b/gluon/tests/test_template.py index 47ac8d44..ee7d3f9b 100644 --- a/gluon/tests/test_template.py +++ b/gluon/tests/test_template.py @@ -66,7 +66,7 @@ class TestTemplate(unittest.TestCase): def testWithDummyFileSystem(self): from os.path import join as pjoin import contextlib - from gluon._compat import StringIO + from pydal._compat import StringIO from gluon.restricted import RestrictedError @contextlib.contextmanager diff --git a/gluon/tests/test_tools.py b/gluon/tests/test_tools.py index fa963144..a615063f 100644 --- a/gluon/tests/test_tools.py +++ b/gluon/tests/test_tools.py @@ -22,7 +22,7 @@ from gluon.dal import DAL, Field from pydal.objects import Table from gluon import tools from gluon.tools import Auth, Mail, Recaptcha, Recaptcha2, prettydate, Expose -from gluon._compat import PY2 +from pydal._compat import PY2 from gluon.globals import Request, Response, Session from gluon.storage import Storage from gluon.languages import translator diff --git a/gluon/tests/test_validators.py b/gluon/tests/test_validators.py index 19a18e16..c77a5b2c 100644 --- a/gluon/tests/test_validators.py +++ b/gluon/tests/test_validators.py @@ -13,7 +13,7 @@ fix_sys_path(__file__) from gluon.validators import * -from gluon._compat import PY2, to_bytes +from pydal._compat import PY2, to_bytes class TestValidators(unittest.TestCase): diff --git a/gluon/tests/test_web.py b/gluon/tests/test_web.py index f7e9ddf3..89f42177 100644 --- a/gluon/tests/test_web.py +++ b/gluon/tests/test_web.py @@ -16,7 +16,7 @@ from .fix_path import fix_sys_path fix_sys_path(__file__) from gluon.contrib.webclient import WebClient -from gluon._compat import urllib2, PY2 +from pydal._compat import urllib2, PY2 webserverprocess = None diff --git a/gluon/tools.py b/gluon/tools.py index d4ef18e6..d5178850 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -12,7 +12,7 @@ Auth, Mail, PluginManager and various utilities import base64 from functools import reduce -from gluon._compat import pickle, thread, urllib2, Cookie, StringIO, configparser, MIMEBase, MIMEMultipart, \ +from pydal._compat import pickle, thread, urllib2, Cookie, StringIO, configparser, MIMEBase, MIMEMultipart, \ MIMEText, Encoders, Charset, long, urllib_quote, iteritems, to_bytes, to_native, add_charset, \ charset_QP, basestring, unicodeT, to_unicode import datetime diff --git a/gluon/utf8.py b/gluon/utf8.py index 21fd12c4..f9672ee7 100644 --- a/gluon/utf8.py +++ b/gluon/utf8.py @@ -11,7 +11,7 @@ Utilities and class for UTF8 strings managing ---------------------------------------------- """ from __future__ import print_function -from gluon._compat import builtin as __builtin__, unicodeT, iteritems, to_unicode, to_native +from pydal._compat import builtin as __builtin__, unicodeT, iteritems, to_unicode, to_native __all__ = ['Utf8'] diff --git a/gluon/utils.py b/gluon/utils.py index fc468a57..5e611b9c 100644 --- a/gluon/utils.py +++ b/gluon/utils.py @@ -23,7 +23,7 @@ import logging import socket import base64 import zlib -from gluon._compat import basestring, pickle, PY2, xrange, to_bytes, to_native +from pydal._compat import basestring, pickle, PY2, xrange, to_bytes, to_native _struct_2_long_long = struct.Struct('=QQ') diff --git a/gluon/validators.py b/gluon/validators.py index 4181c226..2e9fd490 100644 --- a/gluon/validators.py +++ b/gluon/validators.py @@ -21,7 +21,7 @@ import urllib import struct import decimal import unicodedata -from gluon._compat import StringIO, long, unicodeT, to_unicode, urllib_unquote, unichr, to_bytes, PY2, to_unicode, to_native +from pydal._compat import StringIO, long, unicodeT, to_unicode, urllib_unquote, unichr, to_bytes, PY2, to_unicode, to_native from gluon.utils import simple_hash, web2py_uuid, DIGEST_ALG_BY_SIZE from pydal.objects import Field, FieldVirtual, FieldMethod from functools import reduce diff --git a/gluon/widget.py b/gluon/widget.py index 8aeb9b4c..f801b001 100644 --- a/gluon/widget.py +++ b/gluon/widget.py @@ -13,7 +13,7 @@ from __future__ import print_function import datetime import sys -from gluon._compat import StringIO, thread, xrange +from pydal._compat import StringIO, thread, xrange import time import threading import os