Source code for ecpi.common
"""generic classes, functions. Could be used by other projects.
"""
import os.path as osp
[docs]def get_root_eclairs():
"""get the path of the ECLAIRs directory.
:return: path of the root of the ECLAIRs directory
:rtype: string
"""
a = __file__.split('/')
b = "/".join(a[:-3])
return b
[docs]def add_path_eclairs(p_file):
"""add to p_file the path of the ECLAIRs directory.
:return: absolute path of p_file
:rtype: string
"""
return osp.join(get_root_eclairs(), p_file)
[docs]def add_path_tests_eclairs(p_file):
"""add to p_file the path of the ECLAIRs test directory.
The ECLAIRs test directory is ECLAIRs/DATA_TEST.
It is a non committed directory.
:return: absolute path of p_file
:rtype: string
"""
return osp.join(get_root_eclairs(), 'DATA_TEST', p_file)
[docs]def add_path_data_ref_eclairs(p_file):
"""add to p_file the path of the ECLAIRs data directory.
The ECLAIRs data directory is ECLAIRs/ecpi/common/data.
:return: absolute path of p_file
:rtype: string
"""
return osp.join(get_root_eclairs(), 'ecpi/common/data', p_file)
[docs]def add_path_output_eclairs(p_file):
"""add to p_file the path of the ECLAIRs output directory.
The ECLAIRs output directory is ECLAIRs/OUTPUT.
It is a non commited directory.
:return: absolute path of p_file
:rtype: string
"""
return osp.join(get_root_eclairs(), 'OUTPUT', p_file)