Changeset 4822 for waeup/branches/ulif-importers
- Timestamp:
- 15 Jan 2010, 23:36:42 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-importers/src/waeup/datacenter.py
r4789 r4822 78 78 return result 79 79 80 def getLogFiles(self): 81 """Get a list of .msg files. 82 """ 83 result = [] 84 files = self.getFiles() 85 for file in files: 86 if not file.name.endswith('.msg'): 87 continue 88 result.append( 89 LogFile(os.path.join(self.storage, file.name))) 90 return result 91 80 92 def setStoragePath(self, path, move=False, overwrite=False): 81 93 """Set the path where to store files. … … 179 191 return 180 192 193 181 194 class DataCenterFile(object): 182 195 """A description of a file stored in data center. … … 209 222 return size 210 223 224 class LogFile(DataCenterFile): 225 """A description of a log file. 226 """ 227 def __init__(self, context): 228 super(LogFile, self).__init__(context) 229 self._markers = dict() 230 self._parsed = False 231 self.userid = self.getUserId() 232 self.mode = self.getMode() 233 self.stats = self.getStats() 234 self.source = self.getSourcePath() 235 236 def _parseFile(self, maxline=10): 237 """Find markers in a file. 238 """ 239 if self._parsed: 240 return 241 for line in open(self.context, 'rb'): 242 line = line.strip() 243 if not ':' in line: 244 continue 245 name, text = line.split(':', 1) 246 self._markers[name.lower()] = text 247 self._parsed = True 248 return 249 250 def _getMarker(self, marker): 251 marker = marker.lower() 252 if not self._parsed: 253 self._parseFile() 254 if marker in self._markers.keys(): 255 return self._markers[marker] 256 257 def getUserId(self): 258 return self._getMarker('user') or '<UNKNOWN>' 259 260 def getMode(self): 261 return self._getMarker('mode') or '<NOT SET>' 262 263 def getStats(self): 264 return self._getMarker('processed') or '<Info not avail.>' 265 266 def getSourcePath(self): 267 return self._getMarker('source') or None 268 211 269 class Import(object): 212 270 """Helper class to aggregate imports and their data.
Note: See TracChangeset for help on using the changeset viewer.