NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

dep_util.py (1402B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\carbon\common\stdlib\distutils\dep_util.py
      2 __revision__ = '$Id: dep_util.py 82110 2010-06-20 13:38:51Z kristjan.jonsson $'
      3 import os
      4 from distutils.errors import DistutilsFileError
      5 
      6 def newer(source, target):
      7     if not os.path.exists(source):
      8         raise DistutilsFileError("file '%s' does not exist" % os.path.abspath(source))
      9     if not os.path.exists(target):
     10         return True
     11     return os.stat(source).st_mtime > os.stat(target).st_mtime
     12 
     13 
     14 def newer_pairwise(sources, targets):
     15     if len(sources) != len(targets):
     16         raise ValueError, "'sources' and 'targets' must be same length"
     17     n_sources = []
     18     n_targets = []
     19     for source, target in zip(sources, targets):
     20         if newer(source, target):
     21             n_sources.append(source)
     22             n_targets.append(target)
     23 
     24     return (n_sources, n_targets)
     25 
     26 
     27 def newer_group(sources, target, missing = 'error'):
     28     if not os.path.exists(target):
     29         return True
     30     target_mtime = os.stat(target).st_mtime
     31     for source in sources:
     32         if not os.path.exists(source):
     33             if missing == 'error':
     34                 pass
     35             elif missing == 'ignore':
     36                 continue
     37             elif missing == 'newer':
     38                 return True
     39         if os.stat(source).st_mtime > target_mtime:
     40             return True
     41 
     42     return False