def get_license_parser(self, vague=False): '''Get license parser with definitions obtained from a given directory :param path: License definitions directory ''' conf_path = helper.path(get_dir(helper.prepend_cwd(config.METADATA_DIR))) text_path = helper.path(get_dir(helper.prepend_cwd(config.DEFINITIONS_DIR))) (licenses, keywords) = self.get_all_licenses_and_keywords(conf_path, text_path) logger.info('Loaded {} licenses'.format(len(licenses))) return LicenseParser(keywords, licenses, vague)
def load_license(cls, path): cfp = configparser.ConfigParser() cfp.read_file(open(helper.path(path))) #print(cfp.sections()) return License( cfp.get('Metadata', 'name'),\ True,\ cls._format_files(cfp.get('Metadata', 'files')),\ cfp.get('Metadata', 'vague_words').split(' '),\ cls._get_section(cfp, 'Freedoms'),\ cls._get_section(cfp, 'Obligations'),\ cls._get_section(cfp, 'Restrictions'),\ cls._get_section(cfp, 'Compatibility'),\ cfp.get('Metadata', 'short_name'))
def _format_files(cls, files): prefix = get_dir(config.DEFINITIONS_DIR) return [helper.path(os.path.join(prefix, f + '.txt')) \ for f in files.split(' ')]