scripts/lib/utils/files.py
gdetrez 45cc775a82 Fonctions utiles pour manipuler les fichiers
darcs-hash:20061012090847-f46e9-690fb5e25d3c043a8dfea69858fe49597bdb6a89.gz
2006-10-12 11:08:47 +02:00

13 lines
389 B
Python

import datetime, time, os
def ageOfFile(pathToFile):
pathToFile = os.path.expanduser(pathToFile)
return int(time.time()) - os.path.getmtime(pathToFile)
def fileIsOlderThan(pathToFile, days=0, hours=0, minutes=0, seconds=0):
time= (((days*24) + hours) * 60 + minutes) * 60 + seconds
return ageOfFile(pathToFile) > time
def dirIsEmpty(pathToDir):
return os.listdir(pathToDir) == []