本文整理汇总了Python中shutil.copystat方法的典型用法代码示例。如果您正苦于以下问题:Python shutil.copystat方法的具体用法?Python shutil.copystat怎么用?Python shutil.copystat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shutil
的用法示例。
在下文中一共展示了shutil.copystat方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remove_duplication_in_drc_lvs
# 需要导入模块: import shutil [as 别名]
# 或者: from shutil import copystat [as 别名]
def remove_duplication_in_drc_lvs(self) -> None:
"""
Remove conflicting specification statements found in PDK's DRC & LVS decks.
"""
self.logger.info("Remove LAYOUT PATH|LAYOUT PRIMARY|LAYOUT SYSTEM|DRC RESULTS DATABASE|DRC SUMMARY REPORT|LVS REPORT|LVS POWER NAME|LVS GROUND NAME in DRC/LVS Decks")
ruledirs = os.path.join(self.extracted_tarballs_dir, "ASAP7_PDKandLIB.tar/ASAP7_PDKandLIB_v1p5/asap7PDK_r1p5.tar.bz2/asap7PDK_r1p5/calibre/ruledirs")
drc_deck = os.path.join(ruledirs, "drc/drcRules_calibre_asap7_171111a.rul")
lvs_deck = os.path.join(ruledirs, "lvs/lvsRules_calibre_asap7_160819a.rul")
pattern = re.compile(".*(LAYOUT\ PATH|LAYOUT\ PRIMARY|LAYOUT\ SYSTEM|DRC\ RESULTS\ DATABASE|DRC\ SUMMARY\ REPORT|LVS\ REPORT|LVS\ POWER NAME|LVS\ GROUND\ NAME).*\n")
with tempfile.NamedTemporaryFile(delete=False) as tf:
with open(drc_deck, 'r') as f:
tf.write(pattern.sub("", f.read()).encode('utf-8'))
shutil.copystat(drc_deck, tf.name)
shutil.copy(tf.name, drc_deck)
with tempfile.NamedTemporaryFile(delete=False) as tf:
with open(lvs_deck, 'r') as f:
tf.write(pattern.sub("", f.read()).encode('utf-8'))
shutil.copystat(lvs_deck, tf.name)
shutil.copy(tf.name, lvs_deck)
示例2: unpack_directory
# 需要导入模块: import shutil [as 别名]
# 或者: from shutil import copystat [as 别名]
def unpack_directory(filename, extract_dir, progress_filter=default_filter):
""""Unpack" a directory, using the same interface as for archives
Raises ``UnrecognizedFormat`` if `filename` is not a directory
"""
if not os.path.isdir(filename):
raise UnrecognizedFormat("%s is not a directory" % filename)
paths = {
filename: ('', extract_dir),
}
for base, dirs, files in os.walk(filename):
src, dst = paths[base]
for d in dirs:
paths[os.path.join(base, d)] = src + d + '/', os.path.join(dst, d)
for f in files:
target = os.path.join(dst, f)
target = progress_filter(src + f, target)
if not target:
# skip non-files
continue
ensure_directory(target)
f = os.path.join(base, f)
shutil.copyfile(f, target)
shutil.copystat(f, target)
示例3: unpack_directory
# 需要导入模块: import shutil [as 别名]
# 或者: from shutil import copystat [as 别名]
def unpack_directory(filename, extract_dir, progress_filter=default_filter):
""""Unpack" a directory, using the same interface as for archives
Raises ``UnrecognizedFormat`` if `filename` is not a directory
"""
if not os.path.isdir(filename):
raise UnrecognizedFormat("%s is not a directory" % (filename,))
paths = {filename:('',extract_dir)}
for base, dirs, files in os.walk(filename):
src,dst = paths[base]
for d in dirs:
paths[os.path.join(base,d)] = src+d+'/', os.path.join(dst,d)
for f in files:
name = src+f
target = os.path.join(dst,f)
target = progress_filter(src+f, target)
if not target:
continue # skip non-files
ensure_directory(target)
f = os.path.join(base,f)
shutil.copyfile(f, target)
shutil.copystat(f, target)
示例4: CheckLoaderModule
# 需要导入模块: import shutil [as 别名]
# 或者: from shutil import copystat [as 别名]
def CheckLoaderModule(dll_name):
suffix = ""
if is_debug_build: suffix = "_d"
template = os.path.join(this_dir,
"PyISAPI_loader" + suffix + ".dll")
if not os.path.isfile(template):
raise ConfigurationError(
"Template loader '%s' does not exist" % (template,))
# We can't do a simple "is newer" check, as the DLL is specific to the
# Python version. So we check the date-time and size are identical,
# and skip the copy in that case.
src_stat = os.stat(template)
try:
dest_stat = os.stat(dll_name)
except os.error:
same = 0
else:
same = src_stat[stat.ST_SIZE]==dest_stat[stat.ST_SIZE] and \
src_stat[stat.ST_MTIME]==dest_stat[stat.ST_MTIME]
if not same:
log(2, "Updating %s->%s" % (template, dll_name))
shutil.copyfile(template, dll_name)
shutil.copystat(template, dll_name)
else:
log(2, "%s is up to date." % (dll_name,))
示例5: test_copystat_handles_harmless_chflags_errors
# 需要导入模块: import shutil [as 别名]
# 或者: from shutil import copystat [as 别名]
def test_copystat_handles_harmless_chflags_errors(self):
tmpdir = self.mkdtemp()
file1 = os.path.join(tmpdir, 'file1')
file2 = os.path.join(tmpdir, 'file2')
self.write_file(file1, 'xxx')
self.write_file(file2, 'xxx')
def make_chflags_raiser(err):
ex = OSError()
def _chflags_raiser(path, flags):
ex.errno = err
raise ex
return _chflags_raiser
old_chflags = os.chflags
try:
for err in errno.EOPNOTSUPP, errno.ENOTSUP:
os.chflags = make_chflags_raiser(err)
shutil.copystat(file1, file2)
# assert others errors break it
os.chflags = make_chflags_raiser(errno.EOPNOTSUPP + errno.ENOTSUP)
self.assertRaises(OSError, shutil.copystat, file1, file2)
finally:
os.chflags = old_chflags
示例6: unpack_directory
# 需要导入模块: import shutil [as 别名]
# 或者: from shutil import copystat [as 别名]
def unpack_directory(filename, extract_dir, progress_filter=default_filter):
""""Unpack" a directory, using the same interface as for archives
Raises ``UnrecognizedFormat`` if `filename` is not a directory
"""
if not os.path.isdir(filename):
raise UnrecognizedFormat("%s is not a directory" % (filename,))
paths = {filename:('',extract_dir)}
for base, dirs, files in os.walk(filename):
src,dst = paths[base]
for d in dirs:
paths[os.path.join(base,d)] = src+d+'/', os.path.join(dst,d)
for f in files:
target = os.path.join(dst,f)
target = progress_filter(src+f, target)
if not target:
continue # skip non-files
ensure_directory(target)
f = os.path.join(base,f)
shutil.copyfile(f, target)
shutil.copystat(f, target)
示例7: writeData
# 需要导入模块: import shutil [as 别名]
# 或者: from shutil import copystat [as 别名]
def writeData(database, filename, user, option_box=None):
# Rename file, if it exists already, with <filename>.bak
# as it it for normal XML export.
if os.path.isfile(filename):
try:
shutil.copyfile(filename, filename + ".bak")
shutil.copystat(filename, filename + ".bak")
except:
pass
if option_box:
option_box.parse_options()
database = option_box.get_filtered_database(database)
writer = PackageWriter(database, filename, user)
return writer.export()
#-------------------------------------------------------------------------
#
# PackageWriter
#
#-------------------------------------------------------------------------
示例8: fontselector_export_favorites
# 需要导入模块: import shutil [as 别名]
# 或者: from shutil import copystat [as 别名]
def fontselector_export_favorites(filepath, export_mode, zip, favorites_list, fake_user_list, context) :
export_path = absolute_path(filepath)
# create folder
if not os.path.isdir(export_path) :
os.makedirs(export_path)
# copy fonts
if export_mode in {"BOTH", "FAVORITES"} :
for filepath in favorites_list :
newpath = os.path.join(export_path, os.path.basename(filepath))
shutil.copy2(filepath, newpath)
shutil.copystat(filepath, newpath)
if export_mode in {"BOTH", "FAKE_USER"} :
for filepath in fake_user_list :
newpath = os.path.join(export_path, os.path.basename(filepath))
shutil.copy2(filepath, newpath)
shutil.copystat(filepath, newpath)
# create zip archive
if zip :
shutil.make_archive(export_path, 'zip', export_path)
shutil.rmtree(export_path)
return {'FINISHED'}
示例9: test_copystat_handles_harmless_chflags_errors
# 需要导入模块: import shutil [as 别名]
# 或者: from shutil import copystat [as 别名]
def test_copystat_handles_harmless_chflags_errors(self):
tmpdir = self.mkdtemp()
file1 = os.path.join(tmpdir, 'file1')
file2 = os.path.join(tmpdir, 'file2')
write_file(file1, 'xxx')
write_file(file2, 'xxx')
def make_chflags_raiser(err):
ex = OSError()
def _chflags_raiser(path, flags, *, follow_symlinks=True):
ex.errno = err
raise ex
return _chflags_raiser
old_chflags = os.chflags
try:
for err in errno.EOPNOTSUPP, errno.ENOTSUP:
os.chflags = make_chflags_raiser(err)
shutil.copystat(file1, file2)
# assert others errors break it
os.chflags = make_chflags_raiser(errno.EOPNOTSUPP + errno.ENOTSUP)
self.assertRaises(OSError, shutil.copystat, file1, file2)
finally:
os.chflags = old_chflags