本文整理汇总了Python中manifest.Manifest类的典型用法代码示例。如果您正苦于以下问题:Python Manifest类的具体用法?Python Manifest怎么用?Python Manifest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Manifest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, repodir):
Manifest.__init__(self, repodir)
gitdir = os.path.join(repodir, 'manifest.git')
config = GitConfig.ForRepository(gitdir = gitdir)
if config.GetBoolean('repo.mirror'):
worktree = os.path.join(repodir, 'manifest')
relpath = None
else:
worktree = self.topdir
relpath = '.'
self.manifestProject = MetaProject(self, '__manifest__',
gitdir = gitdir,
worktree = worktree,
relpath = relpath)
self._modules = GitConfig(os.path.join(worktree, '.gitmodules'),
pickleFile = os.path.join(
repodir, '.repopickle_gitmodules'
))
self._review = GitConfig(os.path.join(worktree, '.review'),
pickleFile = os.path.join(
repodir, '.repopickle_review'
))
self._Unload()
示例2: show_main
def show_main():
doc = '''Usage: oxt-pkg-show [options] <package-path>
--help Print this screen.
'''
from docopt import docopt
args = docopt(doc)
logging.basicConfig(level=logging.INFO)
package_path = args['<package-path>']
with open_storage(package_path) as pkg:
with resolve_path(pkg, MANIFEST_PATH).open() as f:
manifest = Manifest()
manifest.load(f)
with resolve_path(pkg, DESCRIPTION_PATH).open() as f:
description = Description.parse(f)
from description import print_human_readable
print_human_readable(description, pkg)
for path in manifest:
item = manifest[path]
print path, item['media-type'],
node = resolve_path(pkg, path)
if node:
print '-- OK'
else:
print '-- MISSING'
示例3: test_min_max_diff_with_diff_at_muliples_levels
def test_min_max_diff_with_diff_at_muliples_levels(self):
m1 = ManifestFileParser().build("""\
1foo
2bar
1xyzzy
1blah
2zyxxy
3diff
3baz
""".split("\n"))
m2 = ManifestFileParser().build("""\
1foo
2bar
1xyzzy
1blah
2diff
2zyxxy
3baz
4diff
1diff
""".split("\n"))
self.assertEqual(list(Manifest.diff(m1, m2)), [
(None, "2bar/1xyzzy/2diff"),
("2bar/3diff", None),
(None, "4diff"),
])
self.assertEqual(list(Manifest.diff(m1, m2, recursive = True)), [
(None, "2bar/1xyzzy/2diff"),
("2bar/3diff", None),
(None, "4diff"),
(None, "4diff/1diff"),
])
示例4: test_diff_two_files_vs_file_and_empty_subdir
def test_diff_two_files_vs_file_and_empty_subdir(self):
m1 = Manifest_from_walking_unpacked_tar("two_files.tar")
m2 = Manifest_from_walking_unpacked_tar("file_and_empty_subdir.tar")
self.assertEqual(list(Manifest.diff(m1, m2)), [
("bar", None), (None, "file"), ("foo", None), (None, "subdir")])
self.assertEqual(list(Manifest.diff(m2, m1)), [
(None, "bar"), ("file", None), (None, "foo"), ("subdir", None)])
示例5: test_diff_like
def test_diff_like(self):
for t in TEST_TARS:
m1 = Manifest_from_walking_unpacked_tar(t)
m2 = Manifest_from_walking_unpacked_tar(t)
self.assertEqual(list(Manifest.diff(m1, m2)), [])
self.assertEqual(list(Manifest.diff(m2, m1)), [])
self.assertEqual(m1, m2)
self.assertEqual(m2, m1)
示例6: __init__
def __init__(self, repodir):
Manifest.__init__(self, repodir)
self._manifestFile = os.path.join(repodir, MANIFEST_FILE_NAME)
self.manifestProject = MetaProject(self, 'manifests',
gitdir = os.path.join(repodir, 'manifests.git'),
worktree = os.path.join(repodir, 'manifests'))
self._Unload()
示例7: test_append_dependencies_to_tree_dicts_invalid_version_json
def test_append_dependencies_to_tree_dicts_invalid_version_json(self):
dep_json = {
'buffer': {
'version': False
}
}
with self.assertRaises(RuntimeError) as context:
Manifest.append_dependencies_to_tree(tree(), dep_json)
示例8: test_diff_unlike
def test_diff_unlike(self):
shifted = TEST_TARS[:]
shifted.append(shifted.pop(0))
for t1, t2 in zip(TEST_TARS, shifted):
m1 = Manifest_from_walking_unpacked_tar(t1)
m2 = Manifest_from_walking_unpacked_tar(t2)
self.assertTrue(list(Manifest.diff(m1, m2)))
self.assertTrue(list(Manifest.diff(m2, m1)))
self.assertNotEqual(m1, m2)
self.assertNotEqual(m2, m1)
self.assertEqual(len(list(Manifest.diff(m1, m2))),
len(list(Manifest.diff(m2, m1))))
示例9: get_repo_commit
def get_repo_commit(manifest_file):
"""
build {repository:commit-id} dictionary, return the dict.
"""
manifest = Manifest(manifest_file)
manifest.validate_manifest()
repo_commit_dict = {}
for repo in manifest.repositories:
repo_name = common.strip_suffix(os.path.basename(repo["repository"]), ".git")
commit_id = repo["commit-id"]
repo_commit_dict[repo_name] = commit_id
print "[DEBUG] manifest repo_commit dict:", repo_commit_dict
return repo_commit_dict
示例10: test_nonrecursive
def test_nonrecursive(self):
m1 = self.mfp.build(["bar", "foo", " bar", " foo"])
m2 = self.mfp.build(["foo", " foo", "xyzzy"])
m3 = self.mfp.build(["foo", " bar", " baz", " foo", " foo"])
self.assertEqual(list(Manifest.merge(m1, m2, m3)), [
("bar", None, None),
("foo", "foo", "foo"),
("foo/bar", None, "foo/bar"),
(None, None, "foo/bar/baz"),
("foo/foo", "foo/foo", "foo/foo"),
(None, None, "foo/foo/foo"),
(None, "xyzzy", None)])
# now without recursion
self.assertEqual(list(Manifest.merge(m1, m2, m3, recursive = False)), [
("bar", None, None),
("foo", "foo", "foo"),
(None, "xyzzy", None)])
# and finally with selective recursion (only recurse into "foo"s)
actual = []
gen = Manifest.merge(m1, m2, m3, recursive = False)
try:
t = next(gen)
while True:
actual.append(t)
paths = [p for p in t if p is not None]
self.assertTrue(paths)
path = paths[0]
self.assertEqual([path] * len(paths), paths)
try:
last_component = path.rsplit("/", 1)[1]
except:
last_component = path
if last_component == "foo":
t = gen.send(True)
else:
t = next(gen)
except StopIteration:
pass
self.assertEqual(actual, [
("bar", None, None),
("foo", "foo", "foo"),
("foo/bar", None, "foo/bar"),
("foo/foo", "foo/foo", "foo/foo"),
(None, None, "foo/foo/foo"),
(None, "xyzzy", None)])
示例11: test_max_diff_two_files_vs_files_at_many_levels
def test_max_diff_two_files_vs_files_at_many_levels(self):
m1 = Manifest_from_walking_unpacked_tar("two_files.tar")
m2 = Manifest_from_walking_unpacked_tar("files_at_many_levels.tar")
self.assertEqual(list(Manifest.diff(m1, m2, recursive = True)), [
(None, "baz"), (None, "baz/bar"), (None, "baz/baz"),
(None, "baz/baz/bar"), (None, "baz/baz/baz"), (None, "baz/baz/foo"),
(None, "baz/foo")])
示例12: run
def run(self):
try:
manifest = Manifest(Manifest.locate_file(self.config.cwd))
self.install(manifest)
except MissingNpmShrinkwrap as e:
Log.error(e.message)
sys.exit(1)
示例13: wrap_manifest_file
def wrap_manifest_file(self, file_path):
"""
Generated manifest file
"""
try:
all_prs = self.get_all_related_prs(self.__repo, self.__merge_commit_sha, self.__pr_number)
under_test_prs = self.get_under_test_prs()
# instance of manifest template
manifest = Manifest.instance_of_sample("manifest-pr-gate.json")
# wrap with pr
repo_url_list = [repo["repository"] for repo in manifest.repositories]
for pr in all_prs:
repo, sha1, _ = pr
repo_url = "https://github.com/{0}.git".format(repo)
# uniform the repo_url case, make sure the url is completely consistent with repo in the manifest
repo_url = [url for url in repo_url_list if url.lower() == repo_url][0]
if repo in under_test_prs:
manifest.update_manifest(repo_url, "", sha1, True)
else:
manifest.update_manifest(repo_url, "", sha1, False)
# fill in blank commit with latest commit sha
for repo in manifest.repositories:
if 'commit-id' in repo and repo['commit-id'] == "":
repo_name = "/".join(repo["repository"][:-4].split("/")[3:])
latest_commit = self.get_latest_commit(repo_name, self.__target_branch)
repo["commit-id"] = latest_commit
manifest.validate_manifest()
manifest.dump_to_json_file(file_path)
except Exception as error:
print "ERROR occured in parse manifest: {0}".format(error)
sys.exit(1)
示例14: validate_manifest_files
def validate_manifest_files(self, *args):
"""
validate several manifest files
For example: validate_manifest_files(file1, file2) or
validate_manifest_files(file1, file2, file3)
"""
validate_result = True
for filename in args:
try:
manifest = Manifest(filename)
manifest.validate_manifest()
print "manifest file {0} is valid".format(filename)
except KeyError as error:
print "Failed to validate manifest file {0}".format(filename)
print "\nERROR: \n{0}".format(error.message)
validate_result = False
return validate_result
示例15: __init__
def __init__(self, dest, builddir, git_credential=None, force=False, jobs=1):
self._jenkins_author = config.gitbit_identity["username"]
self._dest_manifest_file = dest
self._builddir = builddir
self._force = force
self._jobs = jobs
self._manifest = Manifest.instance_of_sample()
self.repo_operator = RepoOperator(git_credential)
self.check_builddir()