• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""distutils.dep_util
2
3Utility functions for simple, timestamp-based dependency of files
4and groups of files; also, function based entirely on such
5timestamp dependency analysis."""
6
7import os
8from distutils.errors import DistutilsFileError
9
10
11def 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 ()
30