aboutsummaryrefslogtreecommitdiff
path: root/wqflask/maintenance/dataset
diff options
context:
space:
mode:
authorroot2014-02-20 15:07:55 -0600
committerroot2014-02-20 15:07:55 -0600
commit34cb91c7bb4f49156e60d3b67318834c10f8d0f0 (patch)
treedd29883e92c099734b3815a55033a9beb8011531 /wqflask/maintenance/dataset
parente6e821a84b0c7cc306ef37aee231bffe4fabc604 (diff)
downloadgenenetwork2-34cb91c7bb4f49156e60d3b67318834c10f8d0f0.tar.gz
Committer: root <root@alexandria.uthsc.edu>
On branch master
Diffstat (limited to 'wqflask/maintenance/dataset')
-rw-r--r--wqflask/maintenance/dataset/utilities.py36
1 files changed, 27 insertions, 9 deletions
diff --git a/wqflask/maintenance/dataset/utilities.py b/wqflask/maintenance/dataset/utilities.py
index fac24943..d389e672 100644
--- a/wqflask/maintenance/dataset/utilities.py
+++ b/wqflask/maintenance/dataset/utilities.py
@@ -41,29 +41,47 @@ def overlap(dic1, dic2):
values2.append(value2)
return keys, values1, values2
-def to_db_string_null(s):
+def to_db_string(s, default):
if s:
s = s.strip()
if len(s) == 0:
- return None
+ return default
elif s == 'x':
- return None
+ return default
else:
return s
else:
- return None
+ return default
-def to_db_string_empty(s):
+def to_db_float(s, default):
if s:
s = s.strip()
if len(s) == 0:
- return ''
+ return default
elif s == 'x':
- return ''
+ return default
else:
- return s
+ try:
+ return float(s)
+ except:
+ return default
else:
- return ''
+ return default
+
+def to_db_int(s, default):
+ if s:
+ s = s.strip()
+ if len(s) == 0:
+ return default
+ elif s == 'x':
+ return default
+ else:
+ try:
+ return int(s)
+ except:
+ return default
+ else:
+ return default
def get_config(configfile):
config = ConfigParser.ConfigParser()