本文整理汇总了Python中bindep.depends.Depends.active_rules方法的典型用法代码示例。如果您正苦于以下问题:Python Depends.active_rules方法的具体用法?Python Depends.active_rules怎么用?Python Depends.active_rules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bindep.depends.Depends
的用法示例。
在下文中一共展示了Depends.active_rules方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_list_all
# 需要导入模块: from bindep.depends import Depends [as 别名]
# 或者: from bindep.depends.Depends import active_rules [as 别名]
def test_list_all(self):
depends = Depends(dedent("""\
install1
install2 [test]
install3 [platform:rpm]
install4 [platform:dpkg]
install5 [quark]
install6 [platform:dpkg test]
install7 [quark test]
install8 [platform:dpkg platform:rpm]
install9 [platform:dpkg platform:rpm test]
installA [!platform:dpkg]
installB [!platform:dpkg test]
installC [!platform:dpkg !test]
installD [platform:dpkg !test]
installE [platform:dpkg !platform:rpm]
installF [platform:dpkg !platform:rpm test]
installG [!platform:dpkg !platform:rpm]
installH [!platform:dpkg !platform:rpm test]
installI [!platform:dpkg !platform:rpm !test]
installJ [platform:dpkg !platform:rpm !test]
"""))
rules_dpkg = depends.active_rules(['platform:dpkg'])
result_dpkg = set(r[0] for r in rules_dpkg)
self.assertEqual(result_dpkg,
set(depends.list_all_packages(rules_dpkg,
output_format='newline')))
self.assertEqual(result_dpkg,
set(depends.list_all_packages(rules_dpkg,
output_format='csv')))
rules_dpkg_test = depends.active_rules(['platform:dpkg', 'test'])
result_dpkg_test = set(r[0] for r in rules_dpkg_test)
self.assertEqual(result_dpkg_test, set(depends.list_all_packages(
rules_dpkg_test,
output_format='newline')))
self.assertEqual(result_dpkg_test, set(depends.list_all_packages(
rules_dpkg_test,
output_format='csv')))
rules_rpm = depends.active_rules(['platform:rpm'])
result_rpm = set(r[0] for r in rules_rpm)
self.assertEqual(result_rpm, set(depends.list_all_packages(rules_rpm,
output_format='newline')))
self.assertEqual(result_rpm, set(depends.list_all_packages(rules_rpm,
output_format='csv')))
rules_rpm_test = depends.active_rules(['platform:rpm', 'test'])
result_rpm_test = set(r[0] for r in rules_rpm_test)
self.assertEqual(result_rpm_test,
set(depends.list_all_packages(
rules_rpm_test,
output_format='newline')))
self.assertEqual(result_rpm_test,
set(depends.list_all_packages(
rules_rpm_test,
output_format='csv')))
示例2: test_platforms
# 需要导入模块: from bindep.depends import Depends [as 别名]
# 或者: from bindep.depends.Depends import active_rules [as 别名]
def test_platforms(self):
depends = Depends(dedent("""\
install1
install2 [test]
install3 [platform:rpm]
install4 [platform:dpkg]
install5 [quark]
install6 [platform:dpkg test]
install7 [quark test]
install8 [platform:dpkg platform:rpm]
install9 [platform:dpkg platform:rpm test]
installA [!platform:dpkg]
installB [!platform:dpkg test]
installC [!platform:dpkg !test]
installD [platform:dpkg !test]
installE [platform:dpkg !platform:rpm]
installF [platform:dpkg !platform:rpm test]
installG [!platform:dpkg !platform:rpm]
installH [!platform:dpkg !platform:rpm test]
installI [!platform:dpkg !platform:rpm !test]
installJ [platform:dpkg !platform:rpm !test]
"""))
# Platform-only rules and rules with no platform are activated
# by a matching platform.
self.expectThat(
set(r[0] for r in depends.active_rules(['platform:dpkg'])),
Equals({"install1", "install4", "install8", "installD",
"installE", "installJ"}))
# Non-platform rules matching one-or-more profiles plus any
# matching platform guarded rules.
self.expectThat(
set(r[0] for r in depends.active_rules(['platform:dpkg', 'test'])),
Equals({"install1", "install2", "install4", "install6", "install7",
"install8", "install9", "installE", "installF"}))
# When multiple platforms are present, none-or-any-platform is
# enough to match.
self.expectThat(
set(r[0] for r in depends.active_rules(['platform:rpm'])),
Equals({"install1", "install3", "install8", "installA",
"installC"}))
# If there are any platform profiles on a rule one of them
# must match an active platform even when other profiles match
# for the rule to be active.
self.expectThat(
set(r[0] for r in depends.active_rules(['platform:rpm', 'test'])),
Equals({"install1", "install2", "install3", "install7", "install8",
"install9", "installA", "installB"}))
示例3: test_platforms_include
# 需要导入模块: from bindep.depends import Depends [as 别名]
# 或者: from bindep.depends.Depends import active_rules [as 别名]
def test_platforms_include(self):
# 9 tests for the nine cases of _include in Depends
depends = Depends(dedent("""\
# False, False -> False
install1 [platform:dpkg quark]
# False, None -> False
install2 [platform:dpkg]
# False, True -> False
install3 [platform:dpkg test]
# None, False -> False
install4 [quark]
# None, None -> True
install5
# None, True -> True
install6 [test]
# True, False -> False
install7 [platform:rpm quark]
# True, None -> True
install8 [platform:rpm]
# True, True -> True
install9 [platform:rpm test]
"""))
# With platform:dpkg and quark False and platform:rpm and test
# True, the above mimics the conditions from _include.
self.expectThat(
set(r[0] for r in depends.active_rules(['platform:rpm', 'test'])),
Equals({"install5", "install6", "install8", "install9"}))
示例4: test_parser_accepts_full_path_to_tools
# 需要导入模块: from bindep.depends import Depends [as 别名]
# 或者: from bindep.depends.Depends import active_rules [as 别名]
def test_parser_accepts_full_path_to_tools(self):
# at least yum/dnf allow these instead of mentioning rpm names
depends = Depends(dedent("""\
/usr/bin/bash
"""))
self.assertEqual(
[("/usr/bin/bash", [], [])],
depends.active_rules(["default"]))
示例5: test_parser_patterns
# 需要导入模块: from bindep.depends import Depends [as 别名]
# 或者: from bindep.depends.Depends import active_rules [as 别名]
def test_parser_patterns(self):
depends = Depends(dedent("""\
foo
bar [something]
category/packagename # for gentoo
baz [platform:this platform:that-those]
blaz [platform:rpm !platform:opensuseproject-42.2]
quux [anotherthing !nothing] <=12
womp # and a comment
# a standalone comment and a blank line
# all's ok? good then
"""))
self.assertEqual(len(depends.active_rules(['default'])), 3)
示例6: main
# 需要导入模块: from bindep.depends import Depends [as 别名]
# 或者: from bindep.depends.Depends import active_rules [as 别名]
def main(depends=None):
if depends is None:
try:
content = open("other-requirements.txt", "rt").read()
except IOError:
logging.error("No other-requirements.txt file found.")
return 1
depends = Depends(content)
parser = optparse.OptionParser()
parser.add_option("--profiles", action="store_true", help="List the platform and configuration profiles.")
opts, args = parser.parse_args()
if opts.profiles:
logging.info("Platform profiles:")
for profile in depends.platform_profiles():
logging.info("%s", profile)
logging.info("")
logging.info("Configuration profiles:")
for profile in depends.profiles():
logging.info("%s", profile)
else:
if args:
profiles = args
else:
profiles = ["default"]
profiles = profiles + depends.platform_profiles()
rules = depends.active_rules(profiles)
errors = depends.check_rules(rules)
for error in errors:
if error[0] == "missing":
logging.info("Missing packages:")
logging.info(" %s", " ".join(error[1]))
if error[0] == "badversion":
logging.info("Bad versions of installed packages:")
for pkg, constraint, version in error[1]:
logging.info(" %s version %s does not match %s", pkg, version, constraint)
if errors:
return 1
return 0
示例7: test_positive_selector_not_in_profiles_inactive
# 需要导入模块: from bindep.depends import Depends [as 别名]
# 或者: from bindep.depends.Depends import active_rules [as 别名]
def test_positive_selector_not_in_profiles_inactive(self):
depends = Depends("foo [on]\n")
self.assertEqual([], depends.active_rules(["default"]))
示例8: test_positive_selector_includes_rule
# 需要导入模块: from bindep.depends import Depends [as 别名]
# 或者: from bindep.depends.Depends import active_rules [as 别名]
def test_positive_selector_includes_rule(self):
depends = Depends("foo [on]\n")
self.assertEqual(
[("foo", [(True, "on")], [])],
depends.active_rules(["on", "off"]))
示例9: test_negative_selector_removes_rule
# 需要导入模块: from bindep.depends import Depends [as 别名]
# 或者: from bindep.depends.Depends import active_rules [as 别名]
def test_negative_selector_removes_rule(self):
depends = Depends("foo [!off]\n")
self.assertEqual([], depends.active_rules(["on", "off"]))
示例10: test_no_selector_active
# 需要导入模块: from bindep.depends import Depends [as 别名]
# 或者: from bindep.depends.Depends import active_rules [as 别名]
def test_no_selector_active(self):
depends = Depends("foo\n")
self.assertEqual([("foo", [], [])], depends.active_rules(["default"]))