distutils deputil utility functions for simple timestampbased dependency of files and groups of files also function based entirely on such timestamp dependency analysis import os from distutils errors import distutilsfileerror def newer source target if not os path existssource raise distutilsfileerrorfile s does not exist os path abspathsource if not os path existstarget return 1 from stat import stmtime mtime1 os statsourcestmtime mtime2 os stattargetstmtime return mtime1 mtime2 newer return true if source exists and is more recently modified than target or if source exists and target doesn t return false if both exist and target is the same age or younger than source raise distutilsfileerror if source does not exist newer
import os
from distutils.errors import DistutilsFileError


def newer (source, target):
    
    if not os.path.exists(source):
        raise DistutilsFileError("file '%s' does not exist" %
                                 os.path.abspath(source))
    if not os.path.exists(target):
        return 1

    from stat import ST_MTIME
    mtime1 = os.stat(source)[ST_MTIME]
    mtime2 = os.stat(target)[ST_MTIME]

    return mtime1 > mtime2