예제 #1
0
파일: config.py 프로젝트: UFAL-DSG/alex
def to_project_path(path):
    """Converts a relative or absoulute file system path to a path relative to project root."""
    path = os.path.abspath(path)
    root = env.root()
    if not path.startswith(root):
        raise Exception('Path is outside the root:' + path)
    path = path[len(root):]
    if path.startswith(os.path.sep):
        return path[1:]
    return path
예제 #2
0
파일: config.py 프로젝트: elnaaz/alex
    def __init__(self, file_name=None, project_root=False, config={}):
        """
        Initialises a new Config object.

        Arguments:
            file_name -- path towards the configuration file
            project_root -- whether the path is only relative wrt the project
                root directory (i.e., the 'alex' directory)
            config -- a ready-to-use config dictionary (if specified,
                `file_name' should NOT be specified, otherwise the config from
                `file_name' overwrites the one specified via `config'

        """
        self.config = config

        if project_root:
            file_name = os.path.join(env.root(), file_name)

        if file_name:
            self.load(file_name)
예제 #3
0
파일: config.py 프로젝트: UFAL-DSG/alex
def as_project_path(path):
    return os.path.join(env.root(), path)
예제 #4
0
파일: config.py 프로젝트: kangliqiang/alex
def as_project_path(path):
    return os.path.join(env.root(), path)