import numpy
VERSION = "0.1"
+DEFAULT_PATH = "~/rsrch/data"
+DEFAULT_PATH_REPLACE_STRING = "$DEFAULT$/"
class error (Exception) :
"Basic module error class"
Initialized with log_dir and log_name.
log_dir specifies the base data directory.
If it doesn't exist, log_dir is created.
+
+ If log_dir begins with '$DEFAULT$/', that portion of the path is replaced
+ with the then-current contents of the DEFAULT_PATH module global.
A subdir of log_dir is created (if necessary) named YYYYMMDD,
where YYYYMMDD is the current day in localtime.
"""
cleanname = filename.translate(self.transtable, self.delete_chars)
return cleanname
- def _create_logdir(self, log_dir) :
+ def _normalize_logdir(self, log_dir):
+ length = len(DEFAULT_PATH_REPLACE_STRING)
+ if log_dir[:length] == DEFAULT_PATH_REPLACE_STRING:
+ log_dir = os.path.join(DEFAULT_PATH, log_dir[length:])
log_dir = os.path.expanduser(log_dir)
+ return log_dir
+ def _create_logdir(self, log_dir) :
+ log_dir = self._normalize_logdir(log_dir)
if not os.path.exists(log_dir) :
os.mkdir(log_dir, 0755)
return log_dir