def cli(filepath: str, install: bool, dev: bool, verbose: bool): """ CLI Endpoint: To convert requirements file to pyproject.toml & poetry lock Args: filepath (str): Path to the requirments file install (bool): A Flag. By default, the cli only update the lock without install the deps. Add `--install` flag to install the deps simultaneously. verbose (bool): A Flag. Add `-v` to print out debug logs """ ctx = click.get_current_context() if verbose: logger.setLevel(level="DEBUG") requirements = read_requirments(ctx, filepath) command = ["poetry", "add"] command = command if install else append(command, "--lock") command = append(command, "--dev") if dev else command command = extend(command, requirements) logger.debug(f"[DEBUG] Command list: {command}") logger.debug(f"[DEBUG] Running cmd: {' '.join(command)}") inpty(ctx, command)
def test_read_req1_from_right_path_with_txt(self): self.set_read_requirements_cases() self.tmpPath = self._create_tempfile(self.right_path_txt, self.formatted_content) reqs = read_requirments(self.ctx, self.tmpPath) self.assertEqual(len(reqs), 3) for req in reqs: for r in req.split(";"): self.assertIn(r, self.formatted_content)
def test_read_req_from_right_path_with_rst(self): self.set_read_requirements_cases() self.tmpPath = self._create_tempfile(self.unsupport_fmt_file, self.formatted_content) read_requirments(self.ctx, self.tmpPath)
def test_read_req_from_wrong_path_with_txt(self): self.set_read_requirements_cases() self.tmpPath = self._create_tempfile(self.wrong_path_txt, self.messy_content) read_requirments(self.ctx, self.wrong_path_txt)