Ejemplo n.º 1
0
def get_imports(fips_dir, proj_dir):
    """get the imports from the fips.yml file in proj_dir

    :param proj_dir:    the project directory
    :returns:           dictionary object with imports (can be empty)
    """
    proj_name = util.get_project_name_from_dir(proj_dir)
    imports = {}
    if util.is_valid_project_dir(proj_dir):
        dic = util.load_fips_yml(proj_dir)
        if 'imports' in dic:
            imports = dic['imports']

        # warn if this is an old-style list instead of new style dict
        if imports:
            if type(imports) is list:
                log.warn("imports in '{}/fips.yml' uses obsolete array format".
                         format(proj_dir))

                # convert old style to new dict format
                # FIXME: should be removed after a while
                new_imports = {}
                for dep in imports:
                    dep_url = registry.get_url(fips_dir, dep)
                    if not util.is_git_url(dep_url):
                        log.error(
                            "'{}' cannot be resolved into a git url (in project '{}')"
                            .format(dep_url, proj_name))
                    dep_proj_name = util.get_project_name_from_url(dep_url)
                    new_imports[dep_proj_name] = {}
                    new_imports[dep_proj_name][
                        'git'] = util.get_giturl_from_url(dep_url)
                    new_imports[dep_proj_name][
                        'branch'] = util.get_gitbranch_from_url(dep_url)
                imports = new_imports
            elif type(imports) is dict:
                for dep in imports:
                    if not 'branch' in imports[dep]:
                        imports[dep]['branch'] = 'master'
                    if not 'cond' in imports[dep]:
                        imports[dep]['cond'] = None
                    if not 'git' in imports[dep]:
                        log.error(
                            "no git URL in import '{}' in '{}/fips.yml'!\n".
                            format(dep, proj_dir))
                    if not 'group' in imports[dep]:
                        imports[dep]['group'] = None
            else:
                log.error(
                    "imports in '{}/fips.yml' must be a dictionary!".format(
                        proj_dir))
    return imports
Ejemplo n.º 2
0
Archivo: dep.py Proyecto: floooh/fips
def get_imports(fips_dir, proj_dir) :
    """get the imports from the fips.yml file in proj_dir

    :param proj_dir:    the project directory
    :returns:           dictionary object with imports (can be empty)
    """
    proj_name = util.get_project_name_from_dir(proj_dir)
    imports = {}
    if util.is_valid_project_dir(proj_dir) :
        dic = util.load_fips_yml(proj_dir)
        if 'imports' in dic :
            imports = dic['imports']

        # warn if this is an old-style list instead of new style dict
        if imports :
            if type(imports) is list :
                log.warn("imports in '{}/fips.yml' uses obsolete array format".format(proj_dir))
                
                # convert old style to new dict format
                # FIXME: should be removed after a while
                new_imports = {}
                for dep in imports :
                    dep_url = registry.get_url(fips_dir, dep)
                    if not util.is_git_url(dep_url) :
                        log.error("'{}' cannot be resolved into a git url (in project '{}')".format(dep_url, proj_name))
                    dep_proj_name = util.get_project_name_from_url(dep_url)
                    new_imports[dep_proj_name] = {}
                    new_imports[dep_proj_name]['git']    = util.get_giturl_from_url(dep_url)
                    new_imports[dep_proj_name]['branch'] = util.get_gitbranch_from_url(dep_url)
                imports = new_imports
            elif type(imports) is dict :
                for dep in imports :
                    if not 'branch' in imports[dep] :
                        imports[dep]['branch'] = 'master'
                    if not 'cond' in imports[dep] :
                        imports[dep]['cond'] = None
                    if not 'git' in imports[dep] :
                        log.error("no git URL in import '{}' in '{}/fips.yml'!\n".format(dep, proj_dir))
                    if not 'group' in imports[dep] :
                        imports[dep]['group'] = None
            else :
                log.error("imports in '{}/fips.yml' must be a dictionary!".format(proj_dir))
    return imports
Ejemplo n.º 3
0
def clone(fips_dir, url) :
    """clone an existing fips project with git, do NOT fetch dependencies

    :param fips_dir:    absolute path to fips
    :param url:         git url to clone from (may contain branch name separated by '#')
    :return:            True if project was successfully cloned
    """
    ws_dir = util.get_workspace_dir(fips_dir)
    proj_name = util.get_project_name_from_url(url)
    proj_dir = util.get_project_dir(fips_dir, proj_name)
    if not os.path.isdir(proj_dir) :
        git_url = util.get_giturl_from_url(url)
        git_branch = util.get_gitbranch_from_url(url)
        if git.clone(git_url, git_branch, proj_name, ws_dir) :
            # fetch imports
            dep.fetch_imports(fips_dir, proj_dir)
            return True
        else :
            log.error("failed to 'git clone {}' into '{}'".format(url, proj_dir))
            return False
    else :
        log.error("project dir '{}' already exists".format(proj_dir))
        return False
Ejemplo n.º 4
0
def clone(fips_dir, url) :
    """clone an existing fips project with git, do NOT fetch dependencies

    :param fips_dir:    absolute path to fips
    :param url:         git url to clone from (may contain branch name separated by '#')
    :return:            True if project was successfully cloned
    """
    ws_dir = util.get_workspace_dir(fips_dir)
    proj_name = util.get_project_name_from_url(url)
    proj_dir = util.get_project_dir(fips_dir, proj_name)
    if not os.path.isdir(proj_dir) :
        git_url = util.get_giturl_from_url(url)
        git_branch = util.get_gitbranch_from_url(url)
        if git.clone(git_url, git_branch, git.clone_depth, proj_name, ws_dir) :
            # fetch imports
            dep.fetch_imports(fips_dir, proj_dir)
            return True
        else :
            log.error("failed to 'git clone {}' into '{}'".format(url, proj_dir))
            return False
    else :
        log.error("project dir '{}' already exists".format(proj_dir))
        return False