From 45cc775a823b6d0303d84b60fe8ae76ce0e7d090 Mon Sep 17 00:00:00 2001 From: gdetrez Date: Thu, 12 Oct 2006 11:08:47 +0200 Subject: [PATCH] Fonctions utiles pour manipuler les fichiers darcs-hash:20061012090847-f46e9-690fb5e25d3c043a8dfea69858fe49597bdb6a89.gz --- lib/utils/__init__.py | 0 lib/utils/files.py | 13 +++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 lib/utils/__init__.py create mode 100644 lib/utils/files.py 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) == [] +