(root)/
Python-3.12.0/
Tools/
c-analyzer/
distutils/
dep_util.py
       1  """distutils.dep_util
       2  
       3  Utility functions for simple, timestamp-based dependency of files
       4  and groups of files; also, function based entirely on such
       5  timestamp dependency analysis."""
       6  
       7  import os
       8  from distutils.errors import DistutilsFileError
       9  
      10  
      11  def newer (source, target):
      12      """Return true if 'source' exists and is more recently modified than
      13      'target', or if 'source' exists and 'target' doesn't.  Return false if
      14      both exist and 'target' is the same age or younger than 'source'.
      15      Raise DistutilsFileError if 'source' does not exist.
      16      """
      17      if not os.path.exists(source):
      18          raise DistutilsFileError("file '%s' does not exist" %
      19                                   os.path.abspath(source))
      20      if not os.path.exists(target):
      21          return 1
      22  
      23      from stat import ST_MTIME
      24      mtime1 = os.stat(source)[ST_MTIME]
      25      mtime2 = os.stat(target)[ST_MTIME]
      26  
      27      return mtime1 > mtime2
      28  
      29  # newer ()