本文整理汇总了Python中future.builtins.map方法的典型用法代码示例。如果您正苦于以下问题:Python builtins.map方法的具体用法?Python builtins.map怎么用?Python builtins.map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类future.builtins
的用法示例。
在下文中一共展示了builtins.map方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: format_group_index
# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import map [as 别名]
def format_group_index(group_keys):
group_keys = sorted(group_keys)
num = []
num00 = []
for k, g in groupby(enumerate(group_keys), lambda i_x: i_x[0]-i_x[1]):
group = list(map(itemgetter(1), g))
g_min, g_max = min(group), max(group)
if g_min == g_max:
num.append('{0:01d}'.format(g_min))
num00.append('{0:02d}'.format(g_min))
else:
num.append('{0:01d}-{1:01d}'.format(g_min, g_max))
num00.append('{0:02d}-{1:02d}'.format(g_min, g_max))
return ','.join(num) or '0', ','.join(num00) or '00'
示例2: vals_sorted_by_key
# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import map [as 别名]
def vals_sorted_by_key(adict):
keys = sorted(adict.keys())
return map(adict.get, keys)
示例3: __repr__
# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import map [as 别名]
def __repr__(self):
"""Convert to formal string, for repr()."""
L = [self._year, self._month, self._day, # These are never zero
self._hour, self._minute, self._second, self._microsecond]
if L[-1] == 0:
del L[-1]
if L[-1] == 0:
del L[-1]
s = ", ".join(map(str, L))
s = "%s(%s)" % ('datetime.' + self.__class__.__name__, s)
if self._tzinfo is not None:
assert s[-1:] == ")"
s = s[:-1] + ", tzinfo=%r" % self._tzinfo + ")"
return s
示例4: _requires_unix_version
# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import map [as 别名]
def _requires_unix_version(sysname, min_version):
"""Decorator raising SkipTest if the OS is `sysname` and the version is less
than `min_version`.
For example, @_requires_unix_version('FreeBSD', (7, 2)) raises SkipTest if
the FreeBSD version is less than 7.2.
"""
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kw):
if platform.system() == sysname:
version_txt = platform.release().split('-', 1)[0]
try:
version = tuple(map(int, version_txt.split('.')))
except ValueError:
pass
else:
if version < min_version:
min_version_txt = '.'.join(map(str, min_version))
raise unittest.SkipTest(
"%s version %s or higher required, not %s"
% (sysname, min_version_txt, version_txt))
return func(*args, **kw)
wrapper.min_version = min_version
return wrapper
return decorator
示例5: requires_mac_ver
# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import map [as 别名]
def requires_mac_ver(*min_version):
"""Decorator raising SkipTest if the OS is Mac OS X and the OS X
version if less than min_version.
For example, @requires_mac_ver(10, 5) raises SkipTest if the OS X version
is lesser than 10.5.
"""
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kw):
if sys.platform == 'darwin':
version_txt = platform.mac_ver()[0]
try:
version = tuple(map(int, version_txt.split('.')))
except ValueError:
pass
else:
if version < min_version:
min_version_txt = '.'.join(map(str, min_version))
raise unittest.SkipTest(
"Mac OS X %s or higher required, not %s"
% (min_version_txt, version_txt))
return func(*args, **kw)
wrapper.min_version = min_version
return wrapper
return decorator
# Don't use "localhost", since resolving it uses the DNS under recent
# Windows versions (see issue #18792).
示例6: compute_checksum
# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import map [as 别名]
def compute_checksum(self, data):
return encode_hex(int_to_byte(sum(map(ord, data)) % 256))
示例7: server_thread
# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import map [as 别名]
def server_thread():
try:
bjsonrpc.bjsonrpc_options['threaded'] = True
s = bjsonrpc.createserver(port=JSONRPC_EXT_PORT, handler_factory=QuasarRPCServer)
log.info("quasar: starting jsonrpc service")
s.serve()
log.info("quasar: exiting jsonrpc service")
except Exception:
import traceback
list(map(log.error, traceback.format_exc().split("\n")))
raise