[Assorted-commits] SF.net SVN: assorted: [690] python-commons/trunk/src/commons/files.py
Brought to you by:
yangzhang
|
From: <yan...@us...> - 2008-04-29 23:03:05
|
Revision: 690
http://assorted.svn.sourceforge.net/assorted/?rev=690&view=rev
Author: yangzhang
Date: 2008-04-29 16:03:05 -0700 (Tue, 29 Apr 2008)
Log Message:
-----------
fixed bug in versioned_guard; clarified docstring on versioned_cache
Modified Paths:
--------------
python-commons/trunk/src/commons/files.py
Modified: python-commons/trunk/src/commons/files.py
===================================================================
--- python-commons/trunk/src/commons/files.py 2008-04-29 23:00:50 UTC (rev 689)
+++ python-commons/trunk/src/commons/files.py 2008-04-29 23:03:05 UTC (rev 690)
@@ -130,23 +130,26 @@
version or doesn't exist).
@rtype: bool
"""
+ cache_version = None
try:
with file( path ) as f: cache_version = load(f)
except IOError, (errno, errstr):
if errno != 2: raise
+ print cache_version, fresh_version
+ if cache_version is None or fresh_version > cache_version:
+ with file( path, 'w' ) as f: dump(fresh_version, f)
return True
else:
- if fresh_version > cache_version:
- with file( path, 'w' ) as f: dump(fresh_version, f)
- return True
- else:
- return False
+ return False
def versioned_cache(version_path, fresh_version, cache_path, cache_func):
"""
If fresh_version is newer than the version in version_path, then invoke
cache_func and cache the result in cache_path (using pickle).
+ Note the design flaw with L{versioned_guard}: the updated version value is
+ stored immediately, rather than after updating the cache.
+
@param version_path: The path to the file version.
@type version_path: str
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|