removed duplicated code, using pydal's _compat.py
This commit is contained in:
@@ -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
|
|
||||||
+1
-1
@@ -22,7 +22,7 @@ from gluon.fileutils import read_file, write_file, parse_version
|
|||||||
from gluon.restricted import RestrictedError
|
from gluon.restricted import RestrictedError
|
||||||
from gluon.settings import global_settings
|
from gluon.settings import global_settings
|
||||||
from gluon.cache import CacheOnDisk
|
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:
|
if not global_settings.web2py_runtime_gae:
|
||||||
import site
|
import site
|
||||||
|
|||||||
+1
-1
@@ -40,7 +40,7 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
have_settings = False
|
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:
|
try:
|
||||||
import psutil
|
import psutil
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ import fnmatch
|
|||||||
import os
|
import os
|
||||||
import copy
|
import copy
|
||||||
import random
|
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.storage import Storage, List
|
||||||
from gluon.template import parse_template
|
from gluon.template import parse_template
|
||||||
from gluon.restricted import restricted, compile2
|
from gluon.restricted import restricted, compile2
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ Additions:
|
|||||||
- .pickle: application/python-pickle
|
- .pickle: application/python-pickle
|
||||||
- .w2p': application/w2p
|
- .w2p': application/w2p
|
||||||
"""
|
"""
|
||||||
from gluon._compat import to_native
|
from pydal._compat import to_native
|
||||||
|
|
||||||
__all__ = ['contenttype']
|
__all__ = ['contenttype']
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ is restarted (or reload=True is passed).
|
|||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
from gluon._compat import thread, configparser
|
from pydal._compat import thread, configparser
|
||||||
from gluon.globals import current
|
from gluon.globals import current
|
||||||
|
|
||||||
locker = thread.allocate_lock()
|
locker = thread.allocate_lock()
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ revision3.com
|
|||||||
viddler.com
|
viddler.com
|
||||||
"""
|
"""
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from gluon._compat import FancyURLopener, urllib_quote
|
from pydal._compat import FancyURLopener, urllib_quote
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import cgi
|
import cgi
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import re
|
import re
|
||||||
import urllib
|
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
|
from ast import parse as ast_parse
|
||||||
import ast
|
import ast
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
An interactive, stateful AJAX shell that runs Python code on the server.
|
An interactive, stateful AJAX shell that runs Python code on the server.
|
||||||
"""
|
"""
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from gluon._compat import ClassType, pickle, StringIO
|
from pydal._compat import ClassType, pickle, StringIO
|
||||||
import logging
|
import logging
|
||||||
import new
|
import new
|
||||||
import sys
|
import sys
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ mostly for testing purposes
|
|||||||
Some examples at the bottom.
|
Some examples at the bottom.
|
||||||
"""
|
"""
|
||||||
from __future__ import print_function
|
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 re
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
Support for smart import syntax for web2py applications
|
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 os
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ Debugger support classes
|
|||||||
import logging
|
import logging
|
||||||
import pdb
|
import pdb
|
||||||
import sys
|
import sys
|
||||||
from gluon._compat import Queue
|
from pydal._compat import Queue
|
||||||
|
|
||||||
logger = logging.getLogger("web2py")
|
logger = logging.getLogger("web2py")
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ import logging
|
|||||||
from gluon.http import HTTP
|
from gluon.http import HTTP
|
||||||
from gzip import open as gzopen
|
from gzip import open as gzopen
|
||||||
from gluon.recfile import generate
|
from gluon.recfile import generate
|
||||||
from gluon._compat import PY2
|
from pydal._compat import PY2
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'parse_version',
|
'parse_version',
|
||||||
|
|||||||
+2
-2
@@ -13,7 +13,7 @@ Contains the classes for the global used variables:
|
|||||||
- Session
|
- 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.storage import Storage, List
|
||||||
from gluon.streamer import streamer, stream_file_or_304_or_206, DEFAULT_CHUNK_SIZE
|
from gluon.streamer import streamer, stream_file_or_304_or_206, DEFAULT_CHUNK_SIZE
|
||||||
from gluon.contenttype import contenttype
|
from gluon.contenttype import contenttype
|
||||||
@@ -436,7 +436,7 @@ class Response(Storage):
|
|||||||
self._vars.update(b)
|
self._vars.update(b)
|
||||||
self._view_environment.update(self._vars)
|
self._view_environment.update(self._vars)
|
||||||
if view:
|
if view:
|
||||||
from gluon._compat import StringIO
|
from pydal._compat import StringIO
|
||||||
(obody, oview) = (self.body, self.view)
|
(obody, oview) = (self.body, self.view)
|
||||||
(self.body, self.view) = (StringIO(), view)
|
(self.body, self.view) = (StringIO(), view)
|
||||||
run_view_in(self._view_environment)
|
run_view_in(self._view_environment)
|
||||||
|
|||||||
+7
-6
@@ -7,7 +7,8 @@
|
|||||||
| License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
|
| License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
|
||||||
"""
|
"""
|
||||||
from __future__ import print_function
|
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
|
import re
|
||||||
|
|
||||||
__all__ = ['highlight']
|
__all__ = ['highlight']
|
||||||
@@ -62,7 +63,7 @@ class Highlighter(object):
|
|||||||
Callback for C specific highlighting.
|
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.change_style(token, style)
|
||||||
self.output.append(value)
|
self.output.append(value)
|
||||||
|
|
||||||
@@ -76,7 +77,7 @@ class Highlighter(object):
|
|||||||
Callback for python specific highlighting.
|
Callback for python specific highlighting.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
value = _local_html_escape(match.group(), quote=False)
|
value = local_html_escape(match.group(), quote=False)
|
||||||
if token == 'MULTILINESTRING':
|
if token == 'MULTILINESTRING':
|
||||||
self.change_style(token, style)
|
self.change_style(token, style)
|
||||||
self.output.append(value)
|
self.output.append(value)
|
||||||
@@ -113,7 +114,7 @@ class Highlighter(object):
|
|||||||
Callback for HTML specific highlighting.
|
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.change_style(token, style)
|
||||||
self.output.append(value)
|
self.output.append(value)
|
||||||
if token == 'GOTOPYTHON':
|
if token == 'GOTOPYTHON':
|
||||||
@@ -291,13 +292,13 @@ def highlight(
|
|||||||
'WEB2PY']:
|
'WEB2PY']:
|
||||||
code = Highlighter(language, link, styles).highlight(code)
|
code = Highlighter(language, link, styles).highlight(code)
|
||||||
else:
|
else:
|
||||||
code = _local_html_escape(code, quote=False)
|
code = local_html_escape(code, quote=False)
|
||||||
lines = code.split('\n')
|
lines = code.split('\n')
|
||||||
|
|
||||||
if counter is None:
|
if counter is None:
|
||||||
linenumbers = [''] * len(lines)
|
linenumbers = [''] * len(lines)
|
||||||
elif isinstance(counter, str):
|
elif isinstance(counter, str):
|
||||||
linenumbers = [_local_html_escape(counter, quote=False)] * len(lines)
|
linenumbers = [local_html_escape(counter, quote=False)] * len(lines)
|
||||||
else:
|
else:
|
||||||
linenumbers = [str(i + counter) + '.' for i in
|
linenumbers = [str(i + counter) + '.' for i in
|
||||||
xrange(len(lines))]
|
xrange(len(lines))]
|
||||||
|
|||||||
+3
-3
@@ -20,8 +20,8 @@ import urllib
|
|||||||
import base64
|
import base64
|
||||||
from gluon import sanitizer, decoder
|
from gluon import sanitizer, decoder
|
||||||
import itertools
|
import itertools
|
||||||
from gluon._compat import reduce, pickle, copyreg, HTMLParser, name2codepoint, iteritems, unichr, unicodeT, urllib_quote, to_bytes, \
|
from pydal._compat import reduce, pickle, copyreg, HTMLParser, name2codepoint, iteritems, unichr, unicodeT, urllib_quote, to_bytes, to_native, to_unicode, basestring, urlencode, implements_bool
|
||||||
to_native, to_unicode, _local_html_escape, basestring, urlencode, implements_bool
|
from local_html_escape import local_html_escape
|
||||||
import marshal
|
import marshal
|
||||||
|
|
||||||
from gluon.storage import Storage
|
from gluon.storage import Storage
|
||||||
@@ -129,7 +129,7 @@ def xmlescape(data, quote=True):
|
|||||||
|
|
||||||
|
|
||||||
# ... and do the escaping
|
# ... and do the escaping
|
||||||
data = _local_html_escape(data, quote)
|
data = local_html_escape(data, quote)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ HTTP statuses helpers
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from gluon._compat import iteritems
|
from pydal._compat import iteritems
|
||||||
|
|
||||||
__all__ = ['HTTP', 'redirect']
|
__all__ = ['HTTP', 'redirect']
|
||||||
|
|
||||||
|
|||||||
+3
-4
@@ -18,9 +18,8 @@ import pkgutil
|
|||||||
import logging
|
import logging
|
||||||
from cgi import escape
|
from cgi import escape
|
||||||
from threading import RLock
|
from threading import RLock
|
||||||
from gluon._compat import copyreg, PY2, maketrans, iterkeys, unicodeT, to_unicode, to_bytes, iteritems, _local_html_escape, to_native, \
|
from pydal._compat import copyreg, PY2, maketrans, iterkeys, unicodeT, to_unicode, to_bytes, iteritems, to_native, pjoin
|
||||||
pjoin
|
from local_html_escape import local_html_escape
|
||||||
|
|
||||||
from gluon.portalocker import read_locked, LockedFile
|
from gluon.portalocker import read_locked, LockedFile
|
||||||
from gluon.utf8 import Utf8
|
from gluon.utf8 import Utf8
|
||||||
|
|
||||||
@@ -423,7 +422,7 @@ class lazyT(object):
|
|||||||
return len(str(self))
|
return len(str(self))
|
||||||
|
|
||||||
def xml(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):
|
def encode(self, *a, **b):
|
||||||
return str(self).encode(*a, **b)
|
return str(self).encode(*a, **b)
|
||||||
|
|||||||
@@ -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
|
||||||
+1
-1
@@ -25,7 +25,7 @@ import socket
|
|||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
|
||||||
from gluon._compat import Cookie, urllib2
|
from pydal._compat import Cookie, urllib2
|
||||||
#from thread import allocate_lock
|
#from thread import allocate_lock
|
||||||
|
|
||||||
from gluon.fileutils import abspath, write_file
|
from gluon.fileutils import abspath, write_file
|
||||||
|
|||||||
+1
-1
Submodule gluon/packages/dal updated: 9a5332e45b...79ec4e99d0
+1
-1
@@ -10,7 +10,7 @@ Generates names for cache and session files
|
|||||||
--------------------------------------------
|
--------------------------------------------
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
from gluon._compat import builtin
|
from pydal._compat import builtin
|
||||||
|
|
||||||
def generate(filename, depth=2, base=512):
|
def generate(filename, depth=2, base=512):
|
||||||
if os.path.sep in filename:
|
if os.path.sep in filename:
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ Restricted environment to execute application's code
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from gluon._compat import pickle, ClassType
|
from pydal._compat import pickle, ClassType
|
||||||
import traceback
|
import traceback
|
||||||
import types
|
import types
|
||||||
import os
|
import os
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ from gluon.storage import Storage, List
|
|||||||
from gluon.http import HTTP
|
from gluon.http import HTTP
|
||||||
from gluon.fileutils import abspath, read_file
|
from gluon.fileutils import abspath, read_file
|
||||||
from gluon.settings import global_settings
|
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
|
isdir = os.path.isdir
|
||||||
isfile = os.path.isfile
|
isfile = os.path.isfile
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ import errno
|
|||||||
import socket
|
import socket
|
||||||
import logging
|
import logging
|
||||||
import platform
|
import platform
|
||||||
from gluon._compat import iteritems, to_bytes, StringIO, urllib_unquote
|
from pydal._compat import iteritems, to_bytes, StringIO, urllib_unquote
|
||||||
|
|
||||||
# Define Constants
|
# Define Constants
|
||||||
VERSION = '1.2.6'
|
VERSION = '1.2.6'
|
||||||
|
|||||||
+1
-1
@@ -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 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 import IS_INT_IN_RANGE, IS_DATETIME, IS_IN_DB
|
||||||
from gluon.utils import web2py_uuid
|
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
|
from gluon.storage import Storage
|
||||||
|
|
||||||
USAGE = """
|
USAGE = """
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from gluon.html import TAG, XmlComponent, xmlescape
|
|||||||
from gluon.languages import lazyT
|
from gluon.languages import lazyT
|
||||||
import gluon.contrib.rss2 as rss2
|
import gluon.contrib.rss2 as rss2
|
||||||
import json as json_parser
|
import json as json_parser
|
||||||
from gluon._compat import long, to_native, unicodeT
|
from pydal._compat import long, to_native, unicodeT
|
||||||
|
|
||||||
have_yaml = True
|
have_yaml = True
|
||||||
try:
|
try:
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import platform
|
import platform
|
||||||
from gluon.storage import Storage
|
from gluon.storage import Storage
|
||||||
from gluon._compat import PY2
|
from pydal._compat import PY2
|
||||||
|
|
||||||
global_settings = Storage()
|
global_settings = Storage()
|
||||||
settings = global_settings # legacy compatibility
|
settings = global_settings # legacy compatibility
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ from gluon.globals import Request, Response, Session
|
|||||||
from gluon.storage import Storage, List
|
from gluon.storage import Storage, List
|
||||||
from gluon.admin import w2p_unpack
|
from gluon.admin import w2p_unpack
|
||||||
from pydal.base import BaseAdapter
|
from pydal.base import BaseAdapter
|
||||||
from gluon._compat import iteritems, ClassType
|
from pydal._compat import iteritems, ClassType
|
||||||
|
|
||||||
logger = logging.getLogger("web2py")
|
logger = logging.getLogger("web2py")
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ import urllib
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
import os
|
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.http import HTTP, redirect
|
||||||
from gluon.html import XmlComponent, truncate_string
|
from gluon.html import XmlComponent, truncate_string
|
||||||
from gluon.html import XML, SPAN, TAG, A, DIV, CAT, UL, LI, TEXTAREA, BR, IMG
|
from gluon.html import XML, SPAN, TAG, A, DIV, CAT, UL, LI, TEXTAREA, BR, IMG
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ Provides:
|
|||||||
- Storage; like dictionary allowing also for `obj.foo` for `obj['foo']`
|
- 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
|
import gluon.portalocker as portalocker
|
||||||
|
|
||||||
__all__ = ['List', 'Storage', 'Settings', 'Messages',
|
__all__ = ['List', 'Storage', 'Settings', 'Messages',
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ import re
|
|||||||
import errno
|
import errno
|
||||||
from gluon.http import HTTP
|
from gluon.http import HTTP
|
||||||
from gluon.contenttype import contenttype
|
from gluon.contenttype import contenttype
|
||||||
from gluon._compat import PY2
|
from pydal._compat import PY2
|
||||||
|
|
||||||
|
|
||||||
regex_start_range = re.compile('\d+(?=\-)')
|
regex_start_range = re.compile('\d+(?=\-)')
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ import os
|
|||||||
import cgi
|
import cgi
|
||||||
import logging
|
import logging
|
||||||
from re import compile, sub, escape, DOTALL
|
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:
|
try:
|
||||||
# have web2py
|
# have web2py
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from .fix_path import fix_sys_path
|
|||||||
fix_sys_path(__file__)
|
fix_sys_path(__file__)
|
||||||
|
|
||||||
from gluon.contenttype import contenttype
|
from gluon.contenttype import contenttype
|
||||||
from gluon._compat import iteritems
|
from pydal._compat import iteritems
|
||||||
|
|
||||||
class TestContentType(unittest.TestCase):
|
class TestContentType(unittest.TestCase):
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import os
|
|||||||
from .fix_path import fix_sys_path
|
from .fix_path import fix_sys_path
|
||||||
|
|
||||||
fix_sys_path(__file__)
|
fix_sys_path(__file__)
|
||||||
from gluon._compat import to_bytes
|
from pydal._compat import to_bytes
|
||||||
from gluon.storage import Storage
|
from gluon.storage import Storage
|
||||||
from gluon.contrib import fpdf as fpdf
|
from gluon.contrib import fpdf as fpdf
|
||||||
from gluon.contrib import pyfpdf as pyfpdf
|
from gluon.contrib import pyfpdf as pyfpdf
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class TestDALSubclass(unittest.TestCase):
|
|||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
def testSerialization(self):
|
def testSerialization(self):
|
||||||
from gluon._compat import pickle
|
from pydal._compat import pickle
|
||||||
db = DAL(check_reserved=['all'])
|
db = DAL(check_reserved=['all'])
|
||||||
db.define_table('t_a', Field('f_a'))
|
db.define_table('t_a', Field('f_a'))
|
||||||
db.t_a.insert(f_a='test')
|
db.t_a.insert(f_a='test')
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ fix_sys_path(__file__)
|
|||||||
|
|
||||||
from gluon.globals import Request, Response, Session
|
from gluon.globals import Request, Response, Session
|
||||||
from gluon import URL
|
from gluon import URL
|
||||||
from gluon._compat import basestring
|
from pydal._compat import basestring
|
||||||
|
|
||||||
def setup_clean_session():
|
def setup_clean_session():
|
||||||
request = Request(env={})
|
request = Request(env={})
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ from gluon.html import STYLE, TABLE, TR, TD, TAG, TBODY, THEAD, TEXTAREA, TFOOT,
|
|||||||
from gluon.storage import Storage
|
from gluon.storage import Storage
|
||||||
from gluon.html import XML_pickle, XML_unpickle
|
from gluon.html import XML_pickle, XML_unpickle
|
||||||
from gluon.html import TAG_pickler, TAG_unpickler
|
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):
|
class TestBareHelpers(unittest.TestCase):
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ from .fix_path import fix_sys_path
|
|||||||
fix_sys_path(__file__)
|
fix_sys_path(__file__)
|
||||||
|
|
||||||
from gluon import languages
|
from gluon import languages
|
||||||
from gluon._compat import PY2
|
from pydal._compat import PY2
|
||||||
|
|
||||||
MP_WORKING = 0
|
MP_WORKING = 0
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ from gluon.fileutils import abspath
|
|||||||
from gluon.settings import global_settings
|
from gluon.settings import global_settings
|
||||||
from gluon.http import HTTP
|
from gluon.http import HTTP
|
||||||
from gluon.storage import Storage
|
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
|
logger = None
|
||||||
oldcwd = None
|
oldcwd = None
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ from gluon.fileutils import abspath
|
|||||||
from gluon.settings import global_settings
|
from gluon.settings import global_settings
|
||||||
from gluon.http import HTTP
|
from gluon.http import HTTP
|
||||||
from gluon.storage import Storage
|
from gluon.storage import Storage
|
||||||
from gluon._compat import to_bytes
|
from pydal._compat import to_bytes
|
||||||
|
|
||||||
logger = None
|
logger = None
|
||||||
oldcwd = None
|
oldcwd = None
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ fix_sys_path(__file__)
|
|||||||
|
|
||||||
from gluon.storage import Storage, StorageList, List
|
from gluon.storage import Storage, StorageList, List
|
||||||
from gluon.http import HTTP
|
from gluon.http import HTTP
|
||||||
from gluon._compat import pickle
|
from pydal._compat import pickle
|
||||||
|
|
||||||
|
|
||||||
class TestStorage(unittest.TestCase):
|
class TestStorage(unittest.TestCase):
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class TestTemplate(unittest.TestCase):
|
|||||||
def testWithDummyFileSystem(self):
|
def testWithDummyFileSystem(self):
|
||||||
from os.path import join as pjoin
|
from os.path import join as pjoin
|
||||||
import contextlib
|
import contextlib
|
||||||
from gluon._compat import StringIO
|
from pydal._compat import StringIO
|
||||||
from gluon.restricted import RestrictedError
|
from gluon.restricted import RestrictedError
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ from gluon.dal import DAL, Field
|
|||||||
from pydal.objects import Table
|
from pydal.objects import Table
|
||||||
from gluon import tools
|
from gluon import tools
|
||||||
from gluon.tools import Auth, Mail, Recaptcha, Recaptcha2, prettydate, Expose
|
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.globals import Request, Response, Session
|
||||||
from gluon.storage import Storage
|
from gluon.storage import Storage
|
||||||
from gluon.languages import translator
|
from gluon.languages import translator
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ fix_sys_path(__file__)
|
|||||||
|
|
||||||
|
|
||||||
from gluon.validators import *
|
from gluon.validators import *
|
||||||
from gluon._compat import PY2, to_bytes
|
from pydal._compat import PY2, to_bytes
|
||||||
|
|
||||||
class TestValidators(unittest.TestCase):
|
class TestValidators(unittest.TestCase):
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ from .fix_path import fix_sys_path
|
|||||||
fix_sys_path(__file__)
|
fix_sys_path(__file__)
|
||||||
|
|
||||||
from gluon.contrib.webclient import WebClient
|
from gluon.contrib.webclient import WebClient
|
||||||
from gluon._compat import urllib2, PY2
|
from pydal._compat import urllib2, PY2
|
||||||
|
|
||||||
webserverprocess = None
|
webserverprocess = None
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ Auth, Mail, PluginManager and various utilities
|
|||||||
|
|
||||||
import base64
|
import base64
|
||||||
from functools import reduce
|
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, \
|
MIMEText, Encoders, Charset, long, urllib_quote, iteritems, to_bytes, to_native, add_charset, \
|
||||||
charset_QP, basestring, unicodeT, to_unicode
|
charset_QP, basestring, unicodeT, to_unicode
|
||||||
import datetime
|
import datetime
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ Utilities and class for UTF8 strings managing
|
|||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
"""
|
"""
|
||||||
from __future__ import print_function
|
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']
|
__all__ = ['Utf8']
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ import logging
|
|||||||
import socket
|
import socket
|
||||||
import base64
|
import base64
|
||||||
import zlib
|
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')
|
_struct_2_long_long = struct.Struct('=QQ')
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ import urllib
|
|||||||
import struct
|
import struct
|
||||||
import decimal
|
import decimal
|
||||||
import unicodedata
|
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 gluon.utils import simple_hash, web2py_uuid, DIGEST_ALG_BY_SIZE
|
||||||
from pydal.objects import Field, FieldVirtual, FieldMethod
|
from pydal.objects import Field, FieldVirtual, FieldMethod
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ from __future__ import print_function
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import sys
|
import sys
|
||||||
from gluon._compat import StringIO, thread, xrange
|
from pydal._compat import StringIO, thread, xrange
|
||||||
import time
|
import time
|
||||||
import threading
|
import threading
|
||||||
import os
|
import os
|
||||||
|
|||||||
Reference in New Issue
Block a user