def test_release_prettifying(self): pretty_release = TestPrettier.get_yaml_string("pretty_release.yml") self.assertEqual( komodo.prettier( komodo.load_yaml(os.path.join(INPUT_FOLDER, "ugly_release.yml"))), pretty_release, )
def build_matrix_file(release_base, release_folder, builtins): py27 = load_yaml("{}/{}-py27.yml".format(release_folder, release_base)) py36 = load_yaml("{}/{}-py36.yml".format(release_folder, release_base)) all_packages = set(py36.keys()).union(py27.keys()) compiled = {} for p in all_packages: if p in builtins: compiled[p] = builtins[p] elif py27.get(p) == py36.get(p): compiled[p] = py27.get(p) else: compiled[p] = {"py27": py27.get(p), "py36": py36.get(p)} write_to_file(compiled, "{}.yml".format(release_base), False)
def transpile_releases(matrix_file, output_folder): release_base = os.path.splitext(os.path.basename(matrix_file))[0] release_folder = os.path.dirname(matrix_file) release_matrix = load_yaml("{}.yml".format( os.path.join(release_folder, release_base))) for rhel_ver, py_ver in get_matrix(): release_dict = _build(release_matrix, py_ver, rhel_ver) filename = "{}.yml".format( format_release(release_base, rhel_ver, py_ver)) write_to_file(release_dict, os.path.join(output_folder, filename))
def transpile_releases(matrix_file, output_folder): release_base = os.path.basename(matrix_file).strip(".yml") release_folder = os.path.dirname(matrix_file) release_matrix = load_yaml("{}.yml".format( os.path.join(release_folder, release_base))) for rhel_ver in ("rhel6", "rhel7"): for py_ver in ("py27", "py36"): release_dict = _build(release_matrix, py_ver, rhel_ver) filename = "{rel}-{pyver}-{rhel_version}.yml".format( rel=release_base, pyver=py_ver, rhel_version=rhel_ver) write_to_file(release_dict, os.path.join(output_folder, filename))
def load_all_releases(files): used_versions = {} for filename in files: current_release = load_yaml(filename) for lib, version in current_release.items(): if lib in used_versions: used_versions[lib].append(version) else: used_versions[lib] = [version] return used_versions
def run_cleanup(args, parser): if args.check and args.stdout: parser.error( ArgumentError( message="Only check, stdout can not be used together!", argument=args.check, )) repository = load_yaml(args.repository) release_files = [ filename for sublist in args.releases for filename in sublist ] used_versions = load_all_releases(release_files) unused_versions = find_unused_versions(used_versions, repository) if args.check: if not unused_versions: print("No unused software versions found!") else: print("The following software version are not in use:") for lib, versions in unused_versions.items(): print(lib, versions) return remove_unused_versions(repository=repository, unused_versions=unused_versions) if args.stdout: print(prettier(repository)) return output_file = args.repository if args.output: output_file = args.output write_to_file(repository, output_file) if unused_versions: print("Success! New repository file written to {}".format(output_file)) print("The following software version are not in use:") for lib, versions in unused_versions.items(): print(lib, versions)
def build_matrix_file(release_base, release_folder, builtins): files = {} py_keys = [py_ver for _, py_ver in get_matrix()] for key in py_keys: files[key] = load_yaml("{}/{}-{}.yml".format(release_folder, release_base, key)) all_packages = set( itertools.chain.from_iterable(files[key].keys() for key in files)) compiled = {} for p in all_packages: if p in builtins: compiled[p] = builtins[p] continue if len(set([files[key].get(p) for key in files])) == 1: compiled[p] = next(iter(files.values()))[p] else: compiled[p] = {key: files[key].get(p) for key in py_keys} write_to_file(compiled, "{}.yml".format(release_base), False)
def combine(args): build_matrix_file(args.release_base, args.release_folder, load_yaml(args.override_mapping))
def test_inconsistent_config(self): with self.assertRaises(ValueError): komodo.prettier( komodo.load_yaml( os.path.join(INPUT_FOLDER, "inconsistent_config.yml")))
def test_duplicate_entries(self): with self.assertRaises(SystemExit): komodo.load_yaml( os.path.join(INPUT_FOLDER, "duplicate_repository.yml"))