Пример #1
0
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
    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
def as_project_path(path):
    return os.path.join(env.root(), path)
Пример #4
0
def as_project_path(path):
    return os.path.join(env.root(), path)