aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility
diff options
context:
space:
mode:
authorpjotrp2016-02-23 09:27:57 +0000
committerPjotr Prins2016-04-20 08:53:15 +0000
commit6c0f35e56e8d26a47d210b12c171bb050d1ab150 (patch)
tree83460891b04608f06c90a3d53753f05d11cd22fe /wqflask/utility
parentae8834ac9c0f15f2c397bb6727b8a8079bf175eb (diff)
downloadgenenetwork2-6c0f35e56e8d26a47d210b12c171bb050d1ab150.tar.gz
Fine tuning file locating
Diffstat (limited to 'wqflask/utility')
-rw-r--r--wqflask/utility/tools.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py
index af1ab353..dd40be99 100644
--- a/wqflask/utility/tools.py
+++ b/wqflask/utility/tools.py
@@ -54,10 +54,15 @@ def get_setting(command_id,guess=None):
return command
def valid_bin(bin):
- if os.path.islink(bin) or os.path.isfile(bin):
+ if os.path.islink(bin) or valid_file(bin):
return bin
return None
+def valid_file(fn):
+ if os.path.isfile(fn):
+ return fn
+ return None
+
def valid_path(dir):
if os.path.isdir(dir):
return dir
@@ -89,11 +94,12 @@ def locate(name, subdir=None):
base = base+"/"+subdir
if valid_path(base):
lookfor = base + "/" + name
- if valid_path(lookfor):
+ if valid_file(lookfor):
return lookfor
else:
raise IOError("Can not locate "+lookfor)
- raise IOError("Can not locate "+name)
+ if subdir: sys.stderr.write(subdir)
+ raise IOError("Can not locate "+name+" in "+base)
def locate_without_error(name, subdir=None):
"""
@@ -107,7 +113,7 @@ def locate_without_error(name, subdir=None):
base = base+"/"+subdir
if valid_path(base):
lookfor = base + "/" + name
- if valid_path(lookfor):
+ if valid_file(lookfor):
return lookfor
sys.stderr.write("WARNING: file "+name+" not found\n")
return None