本文整理匯總了Python中future.utils.istext方法的典型用法代碼示例。如果您正苦於以下問題:Python utils.istext方法的具體用法?Python utils.istext怎麽用?Python utils.istext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類future.utils
的用法示例。
在下文中一共展示了utils.istext方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: eval_expr
# 需要導入模塊: from future import utils [as 別名]
# 或者: from future.utils import istext [as 別名]
def eval_expr(self, toks):
"""Evaluates expressions.
Currently only works for expressions that also happen to be valid
python expressions.
"""
logger.debug("Eval: {}".format(toks))
try:
if istext(toks) or isbytes(toks):
val = self.eval(toks, None, self.defs['values'])
elif toks.array_values != '':
val = [self.eval(x, None, self.defs['values'])
for x in toks.array_values]
elif toks.value != '':
val = self.eval(toks.value, None, self.defs['values'])
else:
val = None
return val
except Exception:
logger.debug(" failed eval {} : {}".format(toks, format_exc()))
return None
示例2: find
# 需要導入模塊: from future import utils [as 別名]
# 或者: from future.utils import istext [as 別名]
def find(self, name):
"""Search all definitions for the given name.
"""
res = []
for f in self.file_defs:
fd = self.file_defs[f]
for t in fd:
typ = fd[t]
for k in typ:
if istext(name):
if k == name:
res.append((f, t))
else:
if re.match(name, k):
res.append((f, t, k))
return res
示例3: __lt__
# 需要導入模塊: from future import utils [as 別名]
# 或者: from future.utils import istext [as 別名]
def __lt__(self, other):
if not istext(other):
raise TypeError(self.unorderable_err.format(type(other)))
return super(newstr, self).__lt__(other)
示例4: __le__
# 需要導入模塊: from future import utils [as 別名]
# 或者: from future.utils import istext [as 別名]
def __le__(self, other):
if not istext(other):
raise TypeError(self.unorderable_err.format(type(other)))
return super(newstr, self).__le__(other)
示例5: __gt__
# 需要導入模塊: from future import utils [as 別名]
# 或者: from future.utils import istext [as 別名]
def __gt__(self, other):
if not istext(other):
raise TypeError(self.unorderable_err.format(type(other)))
return super(newstr, self).__gt__(other)
示例6: __ge__
# 需要導入模塊: from future import utils [as 別名]
# 或者: from future.utils import istext [as 別名]
def __ge__(self, other):
if not istext(other):
raise TypeError(self.unorderable_err.format(type(other)))
return super(newstr, self).__ge__(other)
示例7: join
# 需要導入模塊: from future import utils [as 別名]
# 或者: from future.utils import istext [as 別名]
def join(self, iterable_of_bytes):
errmsg = 'sequence item {0}: expected bytes, {1} found'
if isbytes(iterable_of_bytes) or istext(iterable_of_bytes):
raise TypeError(errmsg.format(0, type(iterable_of_bytes)))
for i, item in enumerate(iterable_of_bytes):
if istext(item):
raise TypeError(errmsg.format(i, type(item)))
return newbytes(super(newbytes, self).join(iterable_of_bytes))
示例8: __call__
# 需要導入模塊: from future import utils [as 別名]
# 或者: from future.utils import istext [as 別名]
def __call__(cls, lib, *args, **kwargs):
# Identify the library path.
if istext(lib) or isbytes(lib):
if os.sep not in lib:
lib_path = find_library(lib).path
else:
lib_path = os.path.realpath(lib)
assert os.path.isfile(lib_path),\
'Provided path does not point to a file'
backend_cls = cls.backends[kwargs.get('backend', 'ctypes')]
lib_arch = LibraryPath(lib_path).arch
py_bitness = 64 if sys.maxsize > 2**32 else 32
if lib_arch and py_bitness not in lib_arch:
raise OSError("Library bitness does not match Python's")
lib = lib_path
else:
from .backends import identify_library, get_library_path
backend = identify_library(lib)
backend_cls = cls.backends[backend]
lib_path = get_library_path(lib, backend)
# Check whether or not this library has already been opened.
if lib_path in cls.libs:
return cls.libs[lib_path]
else:
obj = super(CLibraryMeta, backend_cls).__call__(lib, *args,
**kwargs)
cls.libs[lib_path] = obj
return obj
示例9: __init__
# 需要導入模塊: from future import utils [as 別名]
# 或者: from future.utils import istext [as 別名]
def __init__(self, lib, headers, prefix=None, lock_calls=False,
convention='cdll', backend='ctypes', **kwargs):
# name everything using underscores to avoid name collisions with
# library
# Build or store the parser from the header files.
if isinstance(headers, list):
self._headers_ = self._build_parser(headers, kwargs)
elif isinstance(headers, CParser):
self._headers_ = headers
else:
msg = 'Expected a CParser instance or list for headers, not {}'
raise ValueError(msg.format(type(headers)))
self._defs_ = self._headers_.defs
# Create or store the internal representation of the library.
if istext(lib) or isbytes(lib):
self._lib_ = self._link_library(lib, convention)
else:
self._lib_ = lib
# Store the list of prefix.
if prefix is None:
self._prefix_ = []
elif isinstance(prefix, list):
self._prefix_ = prefix
else:
self._prefix_ = [prefix]
self._lock_calls_ = lock_calls
if lock_calls:
self._lock_ = RLock()
self._objs_ = {}
for k in ['values', 'functions', 'types', 'structs', 'unions',
'enums']:
self._objs_[k] = {}
self._all_objs_ = {}
self._structs_ = {}
self._unions_ = {}
示例10: arg_c_type
# 需要導入模塊: from future import utils [as 別名]
# 或者: from future.utils import istext [as 別名]
def arg_c_type(self, arg):
"""Return the type required for the specified argument.
Parameters
----------
arg : int or unicode
Name or index of the argument whose type should be returned.
"""
if istext(arg) or isbytes(arg):
arg = self.arg_inds[arg]
return self.lib._get_type(self.sig[1][arg][1])
示例11: __getitem__
# 需要導入模塊: from future import utils [as 別名]
# 或者: from future.utils import istext [as 別名]
def __getitem__(self, n):
if isinstance(n, int):
arg = self.args[n]
elif istext(n) or isbytes(n):
n = self.find_arg(n)
arg = self.args[n]
else:
raise ValueError("Index must be int or str.")
if n in self.guessed:
arg = arg[0]
return self.lib._extract_val_(arg)