Source code for ecpi.common

"""generic classes, functions. Could be used by other projects.

"""


import os.path as osp


[docs]def add_path_current_module(p_module, p_file): ''' function to define a path :param p_module: path of module :param p_file: path of file :return: a path at the same level that p_module :rtype: string ''' return osp.join(osp.dirname(p_module), p_file)
[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_process_eclairs(p_file): """add to p_file the path of the ECLAIRs processing directory. The ECLAIRs test directory is ECLAIRs/DATA_PROCESS. It is a non committed directory. :return: absolute path of p_file :rtype: string """ return osp.join(get_root_eclairs(), 'DATA_PROCESS', p_file)
[docs]def add_path_data_ref_eclairs(p_file): """add to p_file the path of the ECLAIRs data simulation or analysis directory. :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)