def _convert_pipfile(pipfile, dev=False): pipfile = Pipfile.load(pipfile).pipfile section_names = ["packages"] if dev: section_names.append("dev-packages") sources = pipfile.source return _convert(pipfile, sources, section_names, hashes=False)
def from_pipfile(self): if Pipfile is None: raise ImportError( 'please, install extra requirements: install-requires[pipfile]' ) project = Pipfile.load(self.path) requirements = [] packages = project.get_sections()['packages'].items() for name, version in packages: req = Requirement.from_pipfile(name, version) requirements.append(req.as_line()) return self._parse_requirements(requirements)
def _get_names(self, path): with chdir(path): project = Pipfile.load(path) for req in project.packages: yield req.name
def _get_names(self, path: str) -> Iterator[str]: with chdir(path): project = Pipfile.load(path) for req in project.packages: yield req.name
def _convert_pipfile(pipfile, dev=False): pfile = Pipfile.load(pipfile) requirements = pfile.dev_requirements if dev else pfile.requirements return [req.as_line() for req in requirements]
def main(path_to_project: str) -> None: p: Pipfile = Pipfile.load(path_to_project) with open(path.join(path_to_project, 'requirements.txt'), 'w') as f: f.write("\n".join(req.line_instance.get_line() for req in p.requirements))