forked from pallets-eco/flask-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
149 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
flask.ext.admin._compat | ||
~~~~~~~~~~~~~~~~~~~~~~~ | ||
Some py2/py3 compatibility support based on a stripped down | ||
version of six so we don't have to depend on a specific version | ||
of it. | ||
:copyright: (c) 2013 by Armin Ronacher. | ||
:license: BSD, see LICENSE for more details. | ||
""" | ||
import sys | ||
|
||
PY2 = sys.version_info[0] == 2 | ||
|
||
|
||
if not PY2: | ||
text_type = str | ||
string_types = (str,) | ||
integer_types = (int, ) | ||
|
||
iterkeys = lambda d: iter(d.keys()) | ||
itervalues = lambda d: iter(d.values()) | ||
iteritems = lambda d: iter(d.items()) | ||
|
||
def as_unicode(text): | ||
return str(text) | ||
|
||
from functools import reduce | ||
else: | ||
unicode_type = unicode | ||
text_type = unicode | ||
string_types = (str, unicode) | ||
integer_types = (int, long) | ||
|
||
iterkeys = lambda d: d.iterkeys() | ||
itervalues = lambda d: d.itervalues() | ||
iteritems = lambda d: d.iteritems() | ||
|
||
def as_unicode(text): | ||
return unicode(text) | ||
|
||
reduce = __builtin__.reduce | ||
|
||
|
||
def with_metaclass(meta, *bases): | ||
# 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. Because of internal type checks | ||
# we also need to make sure that we downgrade the custom metaclass | ||
# for one level to something closer to type (that's why __call__ and | ||
# __init__ comes back from type etc.). | ||
# | ||
# This has the advantage over six.with_metaclass in that it does not | ||
# introduce dummy classes into the final MRO. | ||
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, {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.