本文整理匯總了Python中sqlalchemy.util.to_list方法的典型用法代碼示例。如果您正苦於以下問題:Python util.to_list方法的具體用法?Python util.to_list怎麽用?Python util.to_list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sqlalchemy.util
的用法示例。
在下文中一共展示了util.to_list方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: only_on
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import to_list [as 別名]
def only_on(dbs, reason=None):
return only_if(
OrPredicate([SpecPredicate(db) for db in util.to_list(dbs)])
)
示例2: test_from_string
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import to_list [as 別名]
def test_from_string(self):
eq_(util.to_list("xyz"), ["xyz"])
示例3: test_from_set
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import to_list [as 別名]
def test_from_set(self):
spec = util.to_list(set([1, 2, 3]))
assert isinstance(spec, list)
eq_(sorted(spec), [1, 2, 3])
示例4: test_from_dict
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import to_list [as 別名]
def test_from_dict(self):
spec = util.to_list({1: "a", 2: "b", 3: "c"})
assert isinstance(spec, list)
eq_(sorted(spec), [1, 2, 3])
示例5: test_from_tuple
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import to_list [as 別名]
def test_from_tuple(self):
eq_(util.to_list((1, 2, 3)), [1, 2, 3])
示例6: test_from_bytes
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import to_list [as 別名]
def test_from_bytes(self):
eq_(util.to_list(compat.b("abc")), [compat.b("abc")])
eq_(
util.to_list([compat.b("abc"), compat.b("def")]),
[compat.b("abc"), compat.b("def")],
)
示例7: only_on
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import to_list [as 別名]
def only_on(dbs, reason=None):
return only_if(
OrPredicate([Predicate.as_predicate(db) for db in util.to_list(dbs)])
)
示例8: _possible_configs_for_cls
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import to_list [as 別名]
def _possible_configs_for_cls(cls, reasons=None):
all_configs = set(config.Config.all_configs())
if cls.__unsupported_on__:
spec = exclusions.db_spec(*cls.__unsupported_on__)
for config_obj in list(all_configs):
if spec(config_obj):
all_configs.remove(config_obj)
if getattr(cls, '__only_on__', None):
spec = exclusions.db_spec(*util.to_list(cls.__only_on__))
for config_obj in list(all_configs):
if not spec(config_obj):
all_configs.remove(config_obj)
if hasattr(cls, '__requires__'):
requirements = config.requirements
for config_obj in list(all_configs):
for requirement in cls.__requires__:
check = getattr(requirements, requirement)
skip_reasons = check.matching_config_reasons(config_obj)
if skip_reasons:
all_configs.remove(config_obj)
if reasons is not None:
reasons.extend(skip_reasons)
break
if hasattr(cls, '__prefer_requires__'):
non_preferred = set()
requirements = config.requirements
for config_obj in list(all_configs):
for requirement in cls.__prefer_requires__:
check = getattr(requirements, requirement)
if not check.enabled_for_config(config_obj):
non_preferred.add(config_obj)
if all_configs.difference(non_preferred):
all_configs.difference_update(non_preferred)
for db_spec, op, spec in getattr(cls, '__excluded_on__', ()):
for config_obj in list(all_configs):
if not exclusions.skip_if(
exclusions.SpecPredicate(db_spec, op, spec)
).enabled_for_config(config_obj):
all_configs.remove(config_obj)
return all_configs
示例9: _do_skips
# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import to_list [as 別名]
def _do_skips(cls):
reasons = []
all_configs = _possible_configs_for_cls(cls, reasons)
if getattr(cls, '__skip_if__', False):
for c in getattr(cls, '__skip_if__'):
if c():
raise SkipTest("'%s' skipped by %s" % (
cls.__name__, c.__name__)
)
if not all_configs:
if getattr(cls, '__backend__', False):
msg = "'%s' unsupported for implementation '%s'" % (
cls.__name__, cls.__only_on__)
else:
msg = "'%s' unsupported on any DB implementation %s%s" % (
cls.__name__,
", ".join(
"'%s(%s)+%s'" % (
config_obj.db.name,
".".join(
str(dig) for dig in
config_obj.db.dialect.server_version_info),
config_obj.db.driver
)
for config_obj in config.Config.all_configs()
),
", ".join(reasons)
)
raise SkipTest(msg)
elif hasattr(cls, '__prefer_backends__'):
non_preferred = set()
spec = exclusions.db_spec(*util.to_list(cls.__prefer_backends__))
for config_obj in all_configs:
if not spec(config_obj):
non_preferred.add(config_obj)
if all_configs.difference(non_preferred):
all_configs.difference_update(non_preferred)
if config._current not in all_configs:
_setup_config(all_configs.pop(), cls)