projects
/
data_logger.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
dac37a7
)
Added $DEFAULT$ replacement to log_dir path to ease log_dir adjustment.
author
W. Trevor King
<wking@drexel.edu>
Thu, 8 Jan 2009 15:36:20 +0000
(10:36 -0500)
committer
W. Trevor King
<wking@drexel.edu>
Thu, 8 Jan 2009 15:36:20 +0000
(10:36 -0500)
data_logger.py
patch
|
blob
|
history
diff --git
a/data_logger.py
b/data_logger.py
index 72acb7f8960da796cd0565cb0de24710f1ace9bd..3286468cb35fd7bacb78dcf4577a0d552750c57c 100644
(file)
--- a/
data_logger.py
+++ b/
data_logger.py
@@
-32,6
+32,8
@@
import string
import numpy
VERSION = "0.1"
import numpy
VERSION = "0.1"
+DEFAULT_PATH = "~/rsrch/data"
+DEFAULT_PATH_REPLACE_STRING = "$DEFAULT$/"
class error (Exception) :
"Basic module error class"
class error (Exception) :
"Basic module error class"
@@
-48,6
+50,9
@@
class data_log :
Initialized with log_dir and log_name.
log_dir specifies the base data directory.
If it doesn't exist, log_dir is created.
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.
A subdir of log_dir is created (if necessary) named YYYYMMDD,
where YYYYMMDD is the current day in localtime.
@@
-95,8
+100,14
@@
class data_log :
"""
cleanname = filename.translate(self.transtable, self.delete_chars)
return cleanname
"""
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)
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
if not os.path.exists(log_dir) :
os.mkdir(log_dir, 0755)
return log_dir