@@ -109,13 +109,16 @@ def deferred_load(self, url):
109
109
self .loading [url ] = threading .Thread (target = self ._load , args = (url ,))
110
110
self .loading [url ].start ()
111
111
112
+ def cached_files (self ):
113
+ filelist = [ f for f in os .listdir (CACHE_DIR ) if \
114
+ (f .endswith (".xml" ) and os .path .isfile (os .path .join (CACHE_DIR , f )))]
115
+ return filelist
116
+
112
117
def show_cache (self ):
113
- cache_dir = os .path .join (tempfile .gettempdir (), "odml.cache" )
114
- onlyfiles = [f for f in os .listdir (cache_dir ) if os .path .isfile (os .path .join (cache_dir , f ))]
115
118
print ("terminology %s \t updated" % (19 * " " ))
116
119
print (60 * "-" )
117
- for f in onlyfiles :
118
- cache_file = os .path .join (cache_dir , f )
120
+ for f in self . cached_files () :
121
+ cache_file = os .path .join (CACHE_DIR , f )
119
122
file_timestamp = datetime .datetime .fromtimestamp (os .path .getmtime (cache_file ))
120
123
disp_name = '_' .join (f .split ('__' )[1 :])
121
124
if len (disp_name ) > 30 :
@@ -125,11 +128,11 @@ def show_cache(self):
125
128
print (" %s \t %s" % (disp_name , file_timestamp ))
126
129
127
130
def clear_cache (self ):
128
- cache_dir = os .path .join (tempfile .gettempdir (), "odml.cache" )
129
- filelist = [ f for f in os .listdir (cache_dir ) if f .endswith (".xml" ) ]
131
+ filelist = self .cached_files ();
130
132
for f in filelist :
131
- os .remove (os .path .join (cache_dir , f ))
132
-
133
+ os .remove (os .path .join (CACHE_DIR , f ))
134
+ if os .path .exists (FILE_MAP_FILE ):
135
+ os .remove (FILE_MAP_FILE )
133
136
134
137
terminologies = Terminologies ()
135
138
load = terminologies .load
0 commit comments