本文整理汇总了Python中pisi.metadata.MetaData.read方法的典型用法代码示例。如果您正苦于以下问题:Python MetaData.read方法的具体用法?Python MetaData.read怎么用?Python MetaData.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pisi.metadata.MetaData
的用法示例。
在下文中一共展示了MetaData.read方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure_pending
# 需要导入模块: from pisi.metadata import MetaData [as 别名]
# 或者: from pisi.metadata.MetaData import read [as 别名]
def configure_pending():
# start with pending packages
# configure them in reverse topological order of dependency
A = ctx.installdb.list_pending()
order = generate_pending_order(A)
try:
import pisi.comariface as comariface
for x in order:
if ctx.installdb.is_installed(x):
pkginfo = A[x]
pkgname = util.package_name(x, pkginfo.version,
pkginfo.release,
False,
False)
pkg_path = util.join_path(ctx.config.lib_dir(),
'package', pkgname)
m = MetaData()
metadata_path = util.join_path(pkg_path, ctx.const.metadata_xml)
m.read(metadata_path)
# FIXME: we need a full package info here!
pkginfo.name = x
ctx.ui.notify(pisi.ui.configuring, package = pkginfo, files = None)
pisi.comariface.post_install(
pkginfo.name,
m.package.providesComar,
util.join_path(pkg_path, ctx.const.comar_dir),
util.join_path(pkg_path, ctx.const.metadata_xml),
util.join_path(pkg_path, ctx.const.files_xml),
)
ctx.ui.notify(pisi.ui.configured, package = pkginfo, files = None)
ctx.installdb.clear_pending(x)
except ImportError:
raise Error(_("comar package is not fully installed"))
示例2: resurrect_package
# 需要导入模块: from pisi.metadata import MetaData [as 别名]
# 或者: from pisi.metadata.MetaData import read [as 别名]
def resurrect_package(package_fn):
"""Resurrect the package in the PiSi databases"""
from os.path import exists
metadata_xml = util.join_path(ctx.config.lib_dir(), package_fn, ctx.const.metadata_xml)
if not exists(metadata_xml):
raise Error, _("Metadata XML '%s' cannot be found") % metadata_xml
metadata = MetaData()
metadata.read(metadata_xml)
errs = metadata.errors()
if errs:
util.Checks.print_errors(errs)
raise Error, _("MetaData format wrong (%s)") % package_fn
ctx.ui.info(_('* Adding \'%s\' to db... ') % (metadata.package.name), noln=True)
files_xml = util.join_path(ctx.config.lib_dir(), package_fn, ctx.const.files_xml)
if not exists(files_xml):
raise Error, _("Files XML '%s' cannot be found") % files_xml
files = Files()
files.read(files_xml)
if files.errors():
raise Error, _("Invalid %s") % ctx.const.files_xml
import pisi.atomicoperations
pisi.atomicoperations.virtual_install(metadata, files)
ctx.ui.info(_('OK.'))
示例3: configure_pending
# 需要导入模块: from pisi.metadata import MetaData [as 别名]
# 或者: from pisi.metadata.MetaData import read [as 别名]
def configure_pending():
# start with pending packages
# configure them in reverse topological order of dependency
A = ctx.installdb.list_pending()
G_f = pgraph.PGraph(ctx.packagedb, pisi.itembyrepodb.installed) # construct G_f
for x in A.keys():
G_f.add_package(x)
B = A
while len(B) > 0:
Bp = set()
for x in B.keys():
pkg = ctx.packagedb.get_package(x, pisi.itembyrepodb.installed)
for dep in pkg.runtimeDependencies():
if dep.package in G_f.vertices():
G_f.add_dep(x, dep)
B = Bp
if ctx.get_option('debug'):
G_f.write_graphviz(sys.stdout)
order = G_f.topological_sort()
order.reverse()
# Bug 4211
if ctx.componentdb.has_component('system.base'):
order = reorder_base_packages(order)
try:
import pisi.comariface as comariface
for x in order:
if ctx.installdb.is_installed(x):
pkginfo = A[x]
pkgname = util.package_name(x, pkginfo.version,
pkginfo.release,
False,
False)
pkg_path = util.join_path(ctx.config.lib_dir(),
'package', pkgname)
m = MetaData()
metadata_path = util.join_path(pkg_path, ctx.const.metadata_xml)
m.read(metadata_path)
# FIXME: we need a full package info here!
pkginfo.name = x
ctx.ui.notify(pisi.ui.configuring, package = pkginfo, files = None)
pisi.comariface.post_install(
pkginfo.name,
m.package.providesComar,
util.join_path(pkg_path, ctx.const.comar_dir),
util.join_path(pkg_path, ctx.const.metadata_xml),
util.join_path(pkg_path, ctx.const.files_xml),
)
ctx.ui.notify(pisi.ui.configured, package = pkginfo, files = None)
ctx.installdb.clear_pending(x)
except ImportError:
raise Error(_("comar package is not fully installed"))
示例4: configure_pending
# 需要导入模块: from pisi.metadata import MetaData [as 别名]
# 或者: from pisi.metadata.MetaData import read [as 别名]
def configure_pending():
# start with pending packages
# configure them in reverse topological order of dependency
A = ctx.installdb.list_pending()
G_f = pgraph.PGraph(ctx.packagedb) # construct G_f
for x in A.keys():
G_f.add_package(x)
B = A
while len(B) > 0:
Bp = set()
for x in B.keys():
pkg = ctx.packagedb.get_package(x)
for dep in pkg.runtimeDependencies():
if dep.package in G_f.vertices():
G_f.add_dep(x, dep)
B = Bp
if ctx.get_option('debug'):
G_f.write_graphviz(sys.stdout)
order = G_f.topological_sort()
order.reverse()
try:
import pisi.comariface as comariface
for x in order:
if ctx.installdb.is_installed(x):
pkginfo = A[x]
pkgname = util.package_name(x, pkginfo.version,
pkginfo.release,
False,
False)
pkg_path = util.join_path(ctx.config.lib_dir(),
'package', pkgname)
m = MetaData()
metadata_path = util.join_path(pkg_path, ctx.const.metadata_xml)
m.read(metadata_path)
for pcomar in m.package.providesComar:
scriptPath = util.join_path(pkg_path,
ctx.const.comar_dir,
pcomar.script)
comariface.register(pcomar, x, scriptPath)
# FIXME: we need a full package info here!
# Eray, please fix this
# your wish is a command, darling -- eray
pkginfo.name = x
ctx.ui.notify(pisi.ui.configuring, package = pkginfo, files = None)
comariface.run_postinstall(x)
ctx.ui.notify(pisi.ui.configured, package = pkginfo, files = None)
ctx.installdb.clear_pending(x)
except ImportError:
raise Error(_("COMAR: comard not fully installed"))
示例5: resurrect_package
# 需要导入模块: from pisi.metadata import MetaData [as 别名]
# 或者: from pisi.metadata.MetaData import read [as 别名]
def resurrect_package(package_fn):
"""Resurrect the package in the PiSi databases"""
from os.path import exists
metadata_xml = util.join_path(ctx.config.lib_dir(), 'package',
package_fn, ctx.const.metadata_xml)
if not exists(metadata_xml):
raise Error, _("Metadata XML '%s' cannot be found") % metadata_xml
metadata = MetaData()
metadata.read(metadata_xml)
errs = metadata.errors()
if errs:
util.Checks.print_errors(errs)
raise Error, _("MetaData format wrong (%s)") % package_fn
# FIXME: there won't be any previous versions of the same package under /var/lib/pisi
# therefore there won't be any need for this check and __is_virtual_upgrade function
# this is just for backward compatibility for sometime
# yes, this is an ugly hack
passed = False
if ctx.installdb.is_installed(metadata.package.name):
passed = True
if not passed:
ctx.ui.info(_('* Adding \'%s\' to db... ') % (metadata.package.name), noln=True)
files_xml = util.join_path(ctx.config.lib_dir(), 'package',
package_fn, ctx.const.files_xml)
if not exists(files_xml):
raise Error, _("Files XML '%s' cannot be found") % files_xml
files = Files()
files.read(files_xml)
if files.errors():
raise Error, _("Invalid %s") % ctx.const.files_xml
import pisi.atomicoperations
def f(txn):
pisi.atomicoperations.virtual_install(metadata, files, txn)
ctx.txn_proc(f)
if not passed:
ctx.ui.info(_('OK.'))
示例6: configure_pending
# 需要导入模块: from pisi.metadata import MetaData [as 别名]
# 或者: from pisi.metadata.MetaData import read [as 别名]
def configure_pending():
# start with pending packages
# configure them in reverse topological order of dependency
A = ctx.installdb.list_pending()
G_f = pgraph.PGraph(packagedb) # construct G_f
for x in A.keys():
G_f.add_package(x)
B = A
while len(B) > 0:
Bp = set()
for x in B.keys():
pkg = packagedb.get_package(x)
for dep in pkg.runtimeDependencies:
if dep.package in G_f.vertices():
G_f.add_dep(x, dep)
B = Bp
if ctx.get_option('debug'):
G_f.write_graphviz(sys.stdout)
order = G_f.topological_sort()
order.reverse()
try:
import pisi.comariface as comariface
for x in order:
pkginfo = A[x]
pkgname = util.package_name(x, pkginfo.version,
pkginfo.release,
pkginfo.build,
False)
pkg_path = util.join_path(ctx.config.lib_dir(),
pkgname)
m = MetaData()
metadata_path = util.join_path(pkg_path, ctx.const.metadata_xml)
m.read(metadata_path)
for pcomar in m.package.providesComar:
scriptPath = util.join_path(pkg_path,
ctx.const.comar_dir,
pcomar.script)
comariface.register(pcomar, x, scriptPath)
comariface.run_postinstall(x)
ctx.installdb.clear_pending(x)
except ImportError:
raise Error(_("COMAR: comard not fully installed"))
示例7: package
# 需要导入模块: from pisi.metadata import MetaData [as 别名]
# 或者: from pisi.metadata.MetaData import read [as 别名]
class Package:
"""PISI Package Class provides access to a pisi package (.pisi
file)."""
def __init__(self, packagefn, mode='r'):
self.filepath = packagefn
url = URI(packagefn)
if url.is_remote_file():
from fetcher import fetch_url
dest = ctx.config.packages_dir()
self.filepath = join(dest, url.filename())
# FIXME: exists is not enough, also sha1sum check needed \
# when implemented in pisi-index.xml
if not exists(self.filepath):
fetch_url(url, dest, ctx.ui.Progress)
else:
ctx.ui.info(_('%s [cached]') % url.filename())
self.impl = archive.ArchiveZip(self.filepath, 'zip', mode)
def add_to_package(self, fn):
"""Add a file or directory to package"""
self.impl.add_to_archive(fn)
def close(self):
"""Close the package archive"""
self.impl.close()
def extract(self, outdir):
"""Extract entire package contents to directory"""
self.extract_dir('', outdir) # means package root
def extract_files(self, paths, outdir):
"""Extract paths to outdir"""
self.impl.unpack_files(paths, outdir)
def extract_file(self, path, outdir):
"""Extract file with path to outdir"""
self.extract_files([path], outdir)
def extract_dir(self, dir, outdir):
"""Extract directory recursively, this function
copies the directory archiveroot/dir to outdir"""
self.impl.unpack_dir(dir, outdir)
def extract_dir_flat(self, dir, outdir):
"""Extract directory recursively, this function
unpacks the *contents* of directory archiveroot/dir inside outdir
this is the function used by the installer"""
self.impl.unpack_dir_flat(dir, outdir)
def extract_PISI_files(self, outdir):
"""Extract PISI control files: metadata.xml, files.xml,
action scripts, etc."""
self.extract_files([ctx.const.metadata_xml, ctx.const.files_xml], outdir)
self.extract_dir('config', outdir)
def read(self, outdir = None):
if not outdir:
outdir = ctx.config.tmp_dir()
# extract control files
self.extract_PISI_files(outdir)
self.metadata = MetaData()
self.metadata.read( join(outdir, ctx.const.metadata_xml) )
if self.metadata.has_errors():
raise Error, _("MetaData format wrong")
self.files = Files()
self.files.read( join(outdir, ctx.const.files_xml) )
if self.files.has_errors():
raise Error, _("Invalid %s") % ctx.const.files_xml
def pkg_dir(self):
packageDir = self.metadata.package.name + '-' \
+ self.metadata.package.version + '-' \
+ self.metadata.package.release
return join( ctx.config.lib_dir(), packageDir)
def comar_dir(self):
return self.pkg_dir() + ctx.const.comar_dir_suffix
示例8: package
# 需要导入模块: from pisi.metadata import MetaData [as 别名]
# 或者: from pisi.metadata.MetaData import read [as 别名]
class Package:
"""PiSi Package Class provides access to a pisi package (.pisi
file)."""
def __init__(self, packagefn, mode='r'):
self.filepath = packagefn
url = URI(packagefn)
if url.is_remote_file():
self.fetch_remote_file(url)
self.impl = archive.ArchiveZip(self.filepath, 'zip', mode)
def fetch_remote_file(self, url):
from fetcher import fetch_url
dest = ctx.config.packages_dir()
self.filepath = join(dest, url.filename())
if not exists(self.filepath):
try:
fetch_url(url, dest, ctx.ui.Progress)
except pisi.fetcher.FetchError:
# Bug 3465
if ctx.get_option('reinstall'):
raise Error(_("There was a problem while fetching '%s'.\nThe package "
"may have been upgraded. Please try to upgrade the package.") % url);
raise
else:
ctx.ui.info(_('%s [cached]') % url.filename())
def add_to_package(self, fn, an=None):
"""Add a file or directory to package"""
self.impl.add_to_archive(fn, an)
def close(self):
"""Close the package archive"""
self.impl.close()
def extract(self, outdir):
"""Extract entire package contents to directory"""
self.extract_dir('', outdir) # means package root
def extract_files(self, paths, outdir):
"""Extract paths to outdir"""
self.impl.unpack_files(paths, outdir)
def extract_file(self, path, outdir):
"""Extract file with path to outdir"""
self.extract_files([path], outdir)
def extract_dir(self, dir, outdir):
"""Extract directory recursively, this function
copies the directory archiveroot/dir to outdir"""
self.impl.unpack_dir(dir, outdir)
def extract_install(self, outdir):
if self.impl.has_file(ctx.const.install_tar_lzma):
self.extract_file(ctx.const.install_tar_lzma, ctx.config.tmp_dir())
tar = archive.ArchiveTar(join(ctx.config.tmp_dir(), ctx.const.install_tar_lzma), 'tarlzma', False, False)
tar.unpack_dir(outdir)
else:
self.extract_dir_flat('install', outdir)
def extract_dir_flat(self, dir, outdir):
"""Extract directory recursively, this function
unpacks the *contents* of directory archiveroot/dir inside outdir
this is the function used by the installer"""
self.impl.unpack_dir_flat(dir, outdir)
def extract_pisi_files(self, outdir):
"""Extract PiSi control files: metadata.xml, files.xml,
action scripts, etc."""
self.extract_files([ctx.const.metadata_xml, ctx.const.files_xml], outdir)
self.extract_dir('config', outdir)
def get_metadata(self):
"""reads metadata.xml from the PiSi package and returns MetaData object"""
md = MetaData()
md.parse(self.impl.read_file(ctx.const.metadata_xml))
return md
def get_files(self):
"""reads files.xml from the PiSi package and returns Files object"""
files = Files()
files.parse(self.impl.read_file(ctx.const.files_xml))
return files
def read(self, outdir = None):
if not outdir:
outdir = ctx.config.tmp_dir()
# extract control files
self.extract_pisi_files(outdir)
self.metadata = MetaData()
self.metadata.read( join(outdir, ctx.const.metadata_xml) )
errs = self.metadata.errors()
if errs:
util.print_errors(errs)
raise Error, _("MetaData format wrong")
#.........这里部分代码省略.........