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
def get_fips_yml_defines(proj_dir): """loads FIPS defines from fips.yml file, or None if none are specified. :param proj_dir: the project directory :returns: true/false """ if util.is_valid_project_dir(proj_dir): dic = util.load_fips_yml(proj_dir) if 'defines' in dic and type(dic['defines']) is dict: return dic['defines'] return None
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
def get_exports(proj_dir): """get the exports from the fips.yml file in proj_dir :param proj_dir: the project directory :returns: dictionary object with exports (can be empty) """ exports = {} if util.is_valid_project_dir(proj_dir): dic = util.load_fips_yml(proj_dir) if 'exports' in dic: exports = dic['exports'] if not 'header-dirs' in exports: exports['header-dirs'] = [] if not 'lib-dirs' in exports: exports['lib-dirs'] = [] if not 'defines' in exports: exports['defines'] = {} if not 'modules' in exports: exports['modules'] = {} return exports
def get_exports(proj_dir) : """get the exports from the fips.yml file in proj_dir :param proj_dir: the project directory :returns: dictionary object with exports (can be empty) """ exports = {} if util.is_valid_project_dir(proj_dir) : dic = util.load_fips_yml(proj_dir) if 'exports' in dic : exports = dic['exports'] if not 'header-dirs' in exports : exports['header-dirs'] = [] if not 'lib-dirs' in exports : exports['lib-dirs'] = [] if not 'defines' in exports : exports['defines'] = {} if not 'modules' in exports : exports['modules'] = {} return exports
def get_policy(proj_dir, policy): """checks whether a policy is defined in the projects fips.yml and returns its bool value, or the default if not defined. :param proj_dir: the project directory :param policy: the policy string name :returns: true/false """ def_policies = {'no_auto_import': False} if util.is_valid_project_dir(proj_dir): dic = util.load_fips_yml(proj_dir) if 'policies' in dic and type(dic['policies']) is dict: if policy in dic['policies']: return dic['policies'][policy] # not found, return default if policy in def_policies: return def_policies[policy] else: # unknown policy, return None log.error("unknown policy name: '{}'".format(policy)) return None
def get_policy(proj_dir, policy) : """checks whether a policy is defined in the projects fips.yml and returns its bool value, or the default if not defined. :param proj_dir: the project directory :param policy: the policy string name :returns: true/false """ def_policies = { 'no_auto_import': False } if util.is_valid_project_dir(proj_dir) : dic = util.load_fips_yml(proj_dir) if 'policies' in dic and type(dic['policies']) is dict: if policy in dic['policies'] : return dic['policies'][policy] # not found, return default if policy in def_policies : return def_policies[policy] else : # unknown policy, return None log.error("unknown policy name: '{}'".format(policy)) return None