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


Python os.stat_float_times方法代碼示例

本文整理匯總了Python中os.stat_float_times方法的典型用法代碼示例。如果您正苦於以下問題:Python os.stat_float_times方法的具體用法?Python os.stat_float_times怎麽用?Python os.stat_float_times使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在os的用法示例。


在下文中一共展示了os.stat_float_times方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setUp

# 需要導入模塊: import os [as 別名]
# 或者: from os import stat_float_times [as 別名]
def setUp(self):
        self.dirname = support.TESTFN
        self.fname = os.path.join(self.dirname, "f1")

        self.addCleanup(support.rmtree, self.dirname)
        os.mkdir(self.dirname)
        with open(self.fname, 'wb') as fp:
            fp.write(b"ABC")

        def restore_float_times(state):
            with warnings.catch_warnings():
                warnings.simplefilter("ignore", DeprecationWarning)

                os.stat_float_times(state)

        # ensure that st_atime and st_mtime are float
        with warnings.catch_warnings():
            warnings.simplefilter("ignore", DeprecationWarning)

            old_float_times = os.stat_float_times(-1)
            self.addCleanup(restore_float_times, old_float_times)

            os.stat_float_times(True) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:25,代碼來源:test_os.py

示例2: getmtime

# 需要導入模塊: import os [as 別名]
# 或者: from os import stat_float_times [as 別名]
def getmtime(x):
        sft = stat_float_times()
        stat_float_times(True)
        try:
            return _getmtime(x)
        finally:
            stat_float_times(sft) 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:9,代碼來源:plugin.py

示例3: __call__

# 需要導入模塊: import os [as 別名]
# 或者: from os import stat_float_times [as 別名]
def __call__(self, *args, **kwargs):
        """ Run command and return its dependencies and outputs, using before
            and after access times to determine dependencies. """

        # For Python pre-2.5, ensure os.stat() returns float atimes
        old_stat_float = os.stat_float_times()
        os.stat_float_times(True)

        originals = self.file_times()
        if self.atimes == 2:
            befores = originals
            atime_resolution = 0
            mtime_resolution = 0
        else:
            befores = self._age_atimes(originals)
            atime_resolution = FAT_atime_resolution
            mtime_resolution = FAT_mtime_resolution
        shell_keywords = dict(silent=False)
        shell_keywords.update(kwargs)
        shell(*args, **shell_keywords)
        afters = self.file_times()
        deps = []
        outputs = []
        for name in afters:
            if name in befores:
                # if file exists before+after && mtime changed, add to outputs
                # Note: Can't just check that atimes > than we think they were
                #       before because os might have rounded them to a later
                #       date than what we think we set them to in befores.
                #       So we make sure they're > by at least 1/2 the
                #       resolution.  This will work for anything with a
                #       resolution better than FAT.
                if afters[name][1]-mtime_resolution/2 > befores[name][1]:
                    if not self.ignore(name):
                        outputs.append(name)
                elif afters[name][0]-atime_resolution/2 > befores[name][0]:
                    # otherwise add to deps if atime changed
                    if not self.ignore(name):
                        deps.append(name)
            else:
                # file created (in afters but not befores), add as output
                if not self.ignore(name):
                    outputs.append(name)

        if self.atimes < 2:
            # Restore atimes of files we didn't access: not for any functional
            # reason -- it's just to preserve the access time for the user's info
            for name in deps:
                originals.pop(name)
            for name in originals:
                original = originals[name]
                if original != afters.get(name, None):
                    self._utime(name, original[0], original[1])

        os.stat_float_times(old_stat_float)  # restore stat_float_times value
        return deps, outputs 
開發者ID:xorbit,項目名稱:LiFePO4wered-Pi,代碼行數:58,代碼來源:fabricate.py


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