no more import stat in cfs.py, thanks Vladyslav
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.00.0 (2012-07-11 22:05:35) dev
|
Version 2.00.0 (2012-07-11 22:08:08) dev
|
||||||
|
|||||||
+7
-6
@@ -13,7 +13,6 @@ FOR INTERNAL USE ONLY
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import stat
|
|
||||||
import thread
|
import thread
|
||||||
from fileutils import read_file
|
from fileutils import read_file
|
||||||
|
|
||||||
@@ -28,13 +27,15 @@ def getcfs(key, filename, filter=None):
|
|||||||
|
|
||||||
:param key: the cache key
|
:param key: the cache key
|
||||||
:param filename: the file to cache
|
:param filename: the file to cache
|
||||||
:param filter: is the function used for filtering. Normally `filename` is a
|
:param filter: is the function used for filtering. Previous stored data
|
||||||
.py file and `filter` is a function that bytecode compiles the file.
|
(or None) are passed to this function as a parameter (READONLY!!).
|
||||||
In this way the bytecode compiled file is cached. (Default = None)
|
Normally `filename` is a .py file and `filter` is a function that
|
||||||
|
bytecode compiles the file. In this way the bytecode compiled file
|
||||||
|
is cached. (Default = None)
|
||||||
|
|
||||||
This is used on Google App Engine since pyc files cannot be saved.
|
This is used on Google App Engine since pyc files cannot be saved.
|
||||||
"""
|
"""
|
||||||
t = os.stat(filename)[stat.ST_MTIME]
|
t = os.stat(filename).st_mtime
|
||||||
cfs_lock.acquire()
|
cfs_lock.acquire()
|
||||||
item = cfs.get(key, None)
|
item = cfs.get(key, None)
|
||||||
cfs_lock.release()
|
cfs_lock.release()
|
||||||
@@ -43,7 +44,7 @@ def getcfs(key, filename, filter=None):
|
|||||||
if not filter:
|
if not filter:
|
||||||
data = read_file(filename)
|
data = read_file(filename)
|
||||||
else:
|
else:
|
||||||
data = filter()
|
data = filter(item[1] if item else None)
|
||||||
cfs_lock.acquire()
|
cfs_lock.acquire()
|
||||||
cfs[key] = (t, data)
|
cfs[key] = (t, data)
|
||||||
cfs_lock.release()
|
cfs_lock.release()
|
||||||
|
|||||||
Reference in New Issue
Block a user