def install(self, package, value, dev=False): section = "packages" if not dev else "dev_packages" if isinstance(value, dict): table = tomlkit.inline_table() table.update(value) self.document[section][package] = table else: self.document[section][package] = value self.write()
def add_line_to_pipfile(self, line, develop): from pipenv.vendor.requirementslib import Requirement requirement = Requirement.from_line(line) section = self._get_pipfile_section(develop=develop) key = requirement.normalized_name entry = next(iter(requirement.as_pipfile().values())) if isinstance(entry, dict): # HACK: TOMLKit prefers to expand tables by default, but we # always want inline tables here. Also tomlkit.inline_table # does not have `update()`. table = tomlkit.inline_table() for k, v in entry.items(): table[k] = v entry = table section[key] = entry