diff --git a/lib/utils/__init__.py b/lib/utils/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lib/utils/files.py b/lib/utils/files.py new file mode 100644 index 00000000..1bce67c5 --- /dev/null +++ b/lib/utils/files.py @@ -0,0 +1,13 @@ +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) == [] +