本文整理汇总了Python中pisi.files.Files.append方法的典型用法代码示例。如果您正苦于以下问题:Python Files.append方法的具体用法?Python Files.append怎么用?Python Files.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pisi.files.Files
的用法示例。
在下文中一共展示了Files.append方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gen_files_xml
# 需要导入模块: from pisi.files import Files [as 别名]
# 或者: from pisi.files.Files import append [as 别名]
def gen_files_xml(self, package):
"""Generetes files.xml using the path definitions in specfile and
generated files by the build system."""
files = Files()
install_dir = self.bctx.pkg_install_dir()
collisions = check_path_collision(package,
self.spec.packages)
if collisions:
raise Error(_('Path collisions detected'))
d = {}
for pinfo in package.paths:
path = install_dir + pinfo.pathname
for fpath, fhash in util.get_file_hashes(path, collisions, install_dir):
frpath = util.removepathprefix(install_dir, fpath) # relative path
ftype = get_file_type(frpath, package.paths)
try: # broken links can cause problem
fsize = str(os.path.getsize(fpath))
except OSError:
fsize = "0"
d[frpath] = FileInfo(frpath, ftype, fsize, fhash)
for (p, fileinfo) in d.iteritems():
files.append(fileinfo)
files_xml_path = os.path.join(self.bctx.pkg_dir(), ctx.const.files_xml)
files.write(files_xml_path)
self.files = files
示例2: gen_files_xml
# 需要导入模块: from pisi.files import Files [as 别名]
# 或者: from pisi.files.Files import append [as 别名]
def gen_files_xml(self, package):
"""Generates files.xml using the path definitions in specfile and
the files produced by the build system."""
files = Files()
if package.debug_package:
install_dir = self.pkg_debug_dir()
else:
install_dir = self.pkg_install_dir()
# FIXME: We need to expand globs before trying to calculate hashes
# Not on the fly like now.
# we'll exclude collisions in get_file_hashes. Having a
# collisions list is not wrong, we must just handle it :).
collisions = check_path_collision(package, self.spec.packages)
# FIXME: material collisions after expanding globs could be
# reported as errors
d = {}
def add_path(path):
# add the files under material path
for fpath, fhash in util.get_file_hashes(path, collisions, install_dir):
if ctx.get_option('create_static') \
and fpath.endswith(ctx.const.ar_file_suffix) \
and not package.name.endswith(ctx.const.static_name_suffix) \
and util.is_ar_file(fpath):
# if this is an ar file, and this package is not a static package,
# don't include this file into the package.
continue
frpath = util.removepathprefix(install_dir, fpath) # relative path
ftype, permanent = get_file_type(frpath, package.files, install_dir)
fsize = util.dir_size(fpath)
if not os.path.islink(fpath):
st = os.stat(fpath)
else:
st = os.lstat(fpath)
d[frpath] = FileInfo(path=frpath, type=ftype, permanent=permanent,
size=fsize, hash=fhash, uid=str(st.st_uid), gid=str(st.st_gid),
mode=oct(S_IMODE(st.st_mode)))
for pinfo in package.files:
wildcard_path = util.join_path(install_dir, pinfo.path)
for path in glob.glob(wildcard_path):
add_path(path)
for (p, fileinfo) in d.iteritems():
files.append(fileinfo)
files_xml_path = util.join_path(self.pkg_dir(), ctx.const.files_xml)
files.write(files_xml_path)
self.files = files