本文整理汇总了Python中conda.history.History类的典型用法代码示例。如果您正苦于以下问题:Python History类的具体用法?Python History怎么用?Python History使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了History类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
def execute(args, parser):
prefix = context.prefix_w_legacy_search
regex = args.regex
if args.full_name:
regex = r'^%s$' % regex
if args.revisions:
from conda.history import History
h = History(prefix)
if isfile(h.path):
if not context.json:
h.print_log()
else:
stdout_json(h.object_log())
else:
raise CondaFileNotFoundError(h.path)
return
if args.explicit:
print_explicit(prefix, args.md5)
return
if args.canonical:
format = 'canonical'
elif args.export:
format = 'export'
else:
format = 'human'
if context.json:
format = 'canonical'
exitcode = print_packages(prefix, regex, format, piplist=args.pip,
json=context.json,
show_channel_urls=context.show_channel_urls)
return exitcode
示例2: execute
def execute(args, parser):
prefix = common.get_prefix(args)
regex = args.regex
if args.full_name:
regex = r'^%s$' % regex
if args.revisions:
from conda.history import History
h = History(prefix)
if isfile(h.path):
if not args.json:
h.print_log()
else:
common.stdout_json(h.object_log())
else:
common.error_and_exit("No revision log found: %s\n" % h.path,
json=args.json,
error_type="NoRevisionLog")
return
if args.canonical:
format = 'canonical'
elif args.export:
format = 'export'
else:
format = 'human'
if args.json:
format = 'canonical'
exitcode = print_packages(prefix, regex, format, piplist=args.pip, json=args.json)
sys.exit(exitcode)
示例3: execute
def execute(args, parser):
prefix = common.get_prefix(args)
if args.revisions:
from conda.history import History
h = History(prefix)
if isfile(h.path):
if not args.json:
h.print_log()
else:
common.stdout_json(h.object_log())
else:
common.error_and_exit("No revision log found: %s\n" % h.path, json=args.json, error_type="NoRevisionLog")
return
if args.canonical:
format = "canonical"
elif args.export:
format = "export"
else:
format = "human"
if args.json:
format = "canonical"
print_packages(prefix, args.regex, format, piplist=args.pip, json=args.json)
示例4: revert_actions
def revert_actions(prefix, revision=-1):
h = History(prefix)
h.update()
try:
state = h.get_state(revision)
except IndexError:
sys.exit("Error: no such revision: %d" % revision)
curr = h.get_state()
if state == curr:
return {}
actions = ensure_linked_actions(state, prefix)
for dist in curr - state:
示例5: test_minimum_conda_version_error
def test_minimum_conda_version_error():
with tempdir() as prefix:
assert not isfile(join(prefix, 'conda-meta', 'history'))
mkdir_p(join(prefix, 'conda-meta'))
copy2(join(dirname(__file__), 'conda-meta', 'history'),
join(prefix, 'conda-meta', 'history'))
with open(join(prefix, 'conda-meta', 'history'), 'a') as fh:
fh.write("==> 2018-07-09 11:18:09 <==\n")
fh.write("# cmd: blarg\n")
fh.write("# conda version: 42.42.4242\n")
h = History(prefix)
with pytest.raises(CondaUpgradeError) as exc:
h.get_user_requests()
exception_string = repr(exc.value)
print(exception_string)
assert "minimum conda version: 42.42" in exception_string
assert "$ conda install -p" in exception_string
示例6: execute
def execute(args, parser):
prefix = common.get_prefix(args)
if args.revisions:
from conda.history import History
h = History(prefix)
if isfile(h.path):
h.print_log()
else:
sys.stderr.write("No revision log found: %s\n" % h.path)
return
if args.canonical:
format = 'canonical'
elif args.export:
format = 'export'
else:
format = 'human'
sys.exit(list_packages(prefix, args.regex, format=format, piplist=args.pip))
示例7: test_specs_line_parsing_44
def test_specs_line_parsing_44(self):
# New format (>=4.4)
item = History._parse_comment_line("# update specs: [\"param[version='>=1.5.1,<2.0']\"]")
pprint(item)
assert item == {
"action": "update",
"specs": [
"param[version='>=1.5.1,<2.0']",
],
"update_specs": [
"param[version='>=1.5.1,<2.0']",
],
}
示例8: test_conda_comment_version_parsing
def test_conda_comment_version_parsing(self):
assert History._parse_comment_line("# conda version: 4.5.1") == {"conda_version": "4.5.1"}
assert History._parse_comment_line("# conda version: 4.5.1rc1") == {"conda_version": "4.5.1rc1"}
assert History._parse_comment_line("# conda version: 4.5.1dev0") == {"conda_version": "4.5.1dev0"}
示例9: test_specs_line_parsing_43
def test_specs_line_parsing_43(self):
# Old format (<4.4)
item = History._parse_comment_line('# install specs: param >=1.5.1,<2.0')
pprint(item)
assert item == {
'action': 'install',
'specs': [
'param >=1.5.1,<2.0',
],
'update_specs': [
'param >=1.5.1,<2.0',
],
}
item = History._parse_comment_line('# install specs: param >=1.5.1,<2.0,0packagename >=1.0.0,<2.0')
pprint(item)
assert item == {
'action': 'install',
'specs': [
'param >=1.5.1,<2.0',
'0packagename >=1.0.0,<2.0',
],
'update_specs': [
'param >=1.5.1,<2.0',
'0packagename >=1.0.0,<2.0',
],
}
item = History._parse_comment_line('# install specs: python>=3.5.1,jupyter >=1.0.0,<2.0,matplotlib >=1.5.1,<2.0,numpy >=1.11.0,<2.0,pandas >=0.19.2,<1.0,psycopg2 >=2.6.1,<3.0,pyyaml >=3.12,<4.0,scipy >=0.17.0,<1.0')
pprint(item)
assert item == {
'action': 'install',
'specs': [
'python>=3.5.1',
'jupyter >=1.0.0,<2.0',
'matplotlib >=1.5.1,<2.0',
'numpy >=1.11.0,<2.0',
'pandas >=0.19.2,<1.0',
'psycopg2 >=2.6.1,<3.0',
'pyyaml >=3.12,<4.0',
'scipy >=0.17.0,<1.0',
],
'update_specs': [
'python>=3.5.1',
'jupyter >=1.0.0,<2.0',
'matplotlib >=1.5.1,<2.0',
'numpy >=1.11.0,<2.0',
'pandas >=0.19.2,<1.0',
'psycopg2 >=2.6.1,<3.0',
'pyyaml >=3.12,<4.0',
'scipy >=0.17.0,<1.0',
],
}
item = History._parse_comment_line('# install specs: _license >=1.0.0,<2.0')
pprint(item)
assert item == {
'action': 'install',
'specs': [
'_license >=1.0.0,<2.0',
],
'update_specs': [
'_license >=1.0.0,<2.0',
],
}
item = History._parse_comment_line('# install specs: pandas,_license >=1.0.0,<2.0')
pprint(item)
assert item == {
'action': 'install',
'specs': [
'pandas', '_license >=1.0.0,<2.0',
],
'update_specs': [
'pandas', '_license >=1.0.0,<2.0',
],
}