blob: 85df9f6cb02a24274b114e8bf753d178bec80ffc (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
"""module contains general tools forgenenetwork"""
import os
from default_settings import GENENETWORK_FILES
def valid_file(file_name):
"""check if file is valid"""
if os.path.isfile(file_name):
return file_name
return None
def valid_path(dir_name):
"""check if path is valid"""
if os.path.isdir(dir_name):
return dir_name
return None
def locate_ignore_error(name, subdir=None):
"""
Locate a static flat file in the GENENETWORK_FILES environment.
This function does not throw an error when the file is not found
but returns None.
"""
base = GENENETWORK_FILES
if subdir:
base = base+"/"+subdir
if valid_path(base):
lookfor = base + "/" + name
if valid_file(lookfor):
return lookfor
return None
|