def yaml_to_repository(path): with open(path) as fp: data = yaml.load(fp) packages = data.get('packages', []) repository = Repository() parser = PrettyPackageStringParser(EnpkgVersion.from_string) for package_str in packages: package = parser.parse_to_package(package_str, "2.7") repository.add_package(package) return repository
def parse_package_list(packages): """ Yield PackageMetadata instances given an sequence of pretty package strings. Parameters ---------- packages : iterator An iterator of package strings (e.g. 'numpy 1.8.1-1; depends (MKL ~= 10.3)'). """ parser = PrettyPackageStringParser(EnpkgVersion.from_string) for package_str in packages: package = parser.parse_to_package(package_str, PY_VER) full_name = "{0} {1}".format(package.name, package.full_version) yield full_name, package
def _from_pretty_string(cls, s, python_version=PY_VER): """ Create an instance from a pretty string. A pretty string looks as follows:: 'numpy 1.8.1-1; depends (MKL ~= 10.3)' Note ---- Don't use this in production code, only meant to be used for testing. """ # FIXME: local import to workaround circular imports from enstaller.new_solver.package_parser import \ PrettyPackageStringParser parser = PrettyPackageStringParser(EnpkgVersion.from_string) return parser.parse_to_package(s, python_version)