當前位置: 首頁>>代碼示例>>Python>>正文


Python shutil.copystat方法代碼示例

本文整理匯總了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) 
開發者ID:ucb-bar,項目名稱:hammer,代碼行數:22,代碼來源:__init__.py

示例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) 
開發者ID:jpush,項目名稱:jbox,代碼行數:27,代碼來源:archive_util.py

示例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) 
開發者ID:MayOneUS,項目名稱:pledgeservice,代碼行數:25,代碼來源:archive_util.py

示例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,)) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:27,代碼來源:install.py

示例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 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:26,代碼來源:test_shutil.py

示例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) 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:24,代碼來源:archive_util.py

示例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
#
#------------------------------------------------------------------------- 
開發者ID:GenealogyCollective,項目名稱:gprime,代碼行數:26,代碼來源:exportpkg.py

示例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'} 
開發者ID:samytichadou,項目名稱:FontSelector_blender_addon,代碼行數:27,代碼來源:export_favorites.py

示例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 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:26,代碼來源:test_shutil.py


注:本文中的shutil.copystat方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。