本文整理汇总了Python中pisi.package.Package.get_metadata方法的典型用法代码示例。如果您正苦于以下问题:Python Package.get_metadata方法的具体用法?Python Package.get_metadata怎么用?Python Package.get_metadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pisi.package.Package
的用法示例。
在下文中一共展示了Package.get_metadata方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_package
# 需要导入模块: from pisi.package import Package [as 别名]
# 或者: from pisi.package.Package import get_metadata [as 别名]
def add_package(self, path, deltas, repo_uri):
package = Package(path, 'r')
md = package.get_metadata()
md.package.packageSize = os.path.getsize(path)
md.package.packageHash = util.sha1_file(path)
if ctx.config.options and ctx.config.options.absolute_urls:
md.package.packageURI = os.path.realpath(path)
else: # create relative path by default
# TODO: in the future well do all of this with purl/pfile/&helpers
# really? heheh -- future exa
md.package.packageURI = util.removepathprefix(repo_uri, path)
# check package semantics
errs = md.errors()
if md.errors():
ctx.ui.error(_('Package %s: metadata corrupt, skipping...') % md.package.name)
ctx.ui.error(unicode(Error(*errs)))
else:
# No need to carry these with index (#3965)
md.package.files = None
md.package.additionalFiles = None
if md.package.name in deltas:
for delta_path in deltas[md.package.name]:
delta = metadata.Delta()
delta.packageURI = util.removepathprefix(repo_uri, delta_path)
delta.packageSize = os.path.getsize(delta_path)
delta.packageHash = util.sha1_file(delta_path)
name, buildFrom, buildTo = util.parse_delta_package_name(delta_path)
delta.buildFrom = buildFrom
md.package.deltaPackages.append(delta)
self.packages.append(md.package)
示例2: add_package
# 需要导入模块: from pisi.package import Package [as 别名]
# 或者: from pisi.package.Package import get_metadata [as 别名]
def add_package(self, path, repo_uri):
package = Package(path, 'r')
md = package.get_metadata()
md.package.packageSize = os.path.getsize(path)
md.package.packageHash = util.sha1_file(path)
if ctx.config.options and ctx.config.options.absolute_urls:
md.package.packageURI = os.path.realpath(path)
else: # create relative path by default
# TODO: in the future well do all of this with purl/pfile/&helpers
# really? heheh -- future exa
md.package.packageURI = util.removepathprefix(repo_uri, path)
# check package semantics
errs = md.errors()
if md.errors():
ctx.ui.error(_('Package %s: metadata corrupt, skipping...') % md.package.name)
ctx.ui.error(unicode(Error(*errs)))
else:
self.packages.append(md.package)
示例3: create_delta_package
# 需要导入模块: from pisi.package import Package [as 别名]
# 或者: from pisi.package.Package import get_metadata [as 别名]
def create_delta_package(old_package, new_package):
if old_package == new_package:
ctx.ui.error(_("Cannot create delta for same package!"))
return
oldpkg = Package(old_package, "r")
newpkg = Package(new_package, "r")
newmd = newpkg.get_metadata()
oldmd = oldpkg.get_metadata()
oldfiles = oldpkg.get_files()
newfiles = newpkg.get_files()
files_delta = find_delta(oldfiles, newfiles)
ctx.ui.info(_("Creating delta PiSi package between %s %s") % (old_package, new_package))
# Unpack new package to temp
newpkg_name = util.package_name(newmd.package.name, newmd.package.version, newmd.package.release, newmd.package.build, False)
newpkg_path = util.join_path(ctx.config.tmp_dir(), newpkg_name)
newpkg.extract_to(newpkg_path, True)
tar = archive.ArchiveTar(util.join_path(newpkg_path, ctx.const.install_tar_lzma), "tarlzma", False, False)
tar.unpack_dir(newpkg_path)
# Create delta package
deltaname = "%s-%s-%s%s" % (oldmd.package.name, oldmd.package.build, newmd.package.build, ctx.const.delta_package_suffix)
outdir = ctx.get_option("output_dir")
if outdir:
deltaname = util.join_path(outdir, deltaname)
deltapkg = Package(deltaname, "w")
c = os.getcwd()
os.chdir(newpkg_path)
# add comar files to package
for pcomar in newmd.package.providesComar:
fname = util.join_path(ctx.const.comar_dir, pcomar.script)
deltapkg.add_to_package(fname)
# add xmls and files
deltapkg.add_to_package(ctx.const.metadata_xml)
deltapkg.add_to_package(ctx.const.files_xml)
# only metadata information may change in a package, so no install.tar.lzma added to delta package
if files_delta:
ctx.build_leftover = util.join_path(ctx.config.tmp_dir(), ctx.const.install_tar_lzma)
tar = archive.ArchiveTar(util.join_path(ctx.config.tmp_dir(), ctx.const.install_tar_lzma), "tarlzma")
for file in files_delta:
tar.add_to_archive(file.path)
tar.close()
os.chdir(ctx.config.tmp_dir())
deltapkg.add_to_package(ctx.const.install_tar_lzma)
deltapkg.close()
tmp_file = util.join_path(ctx.config.tmp_dir(), ctx.const.install_tar_lzma)
if os.path.exists(tmp_file):
os.unlink(tmp_file)
ctx.build_leftover = None
os.chdir(c)
ctx.ui.info(_("Done."))