Fonctions utiles pour manipuler les fichiers
darcs-hash:20061012090847-f46e9-690fb5e25d3c043a8dfea69858fe49597bdb6a89.gz
This commit is contained in:
parent
6de66ae16c
commit
45cc775a82
2 changed files with 13 additions and 0 deletions
0
lib/utils/__init__.py
Normal file
0
lib/utils/__init__.py
Normal file
13
lib/utils/files.py
Normal file
13
lib/utils/files.py
Normal file
|
@ -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) == []
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue