PK!Dpoetrify/__init__.py__version__ = "0.2.1" PK!\poetrify/cli.py#!/usr/bin/env python import errno import os import subprocess import sys from pathlib import Path from cleo import Application from cleo import Command from . import __version__ from .core import generate_init_cmd application = Application("poetrify", __version__, complete=True) class GenerateCommand(Command): """ Generate pyproject.toml from Pipfile generate {--w|workspace= : Working space} {--d|dry-run : Only display the generated command.} """ def handle(self): _workspace = self.option("workspace") if _workspace: workspace = Path(_workspace) os.chdir(workspace) else: workspace = Path(".") cmd = generate_init_cmd() if not cmd: self.line_error("[ERROR] Pipfile not found.", style="error") sys.exit(errno.ENOENT) self.info("Generated init command:") self.line(f"\n{cmd}\n") self.line("") if self.option("dry-run"): sys.exit(os.EX_OK) self.info( "Execute the above command. Also, the following output is due to Poetry." ) r = subprocess.run(cmd, shell=True) if r.returncode != os.EX_OK: sys.exit(r.returncode) pipfile = workspace / "Pipfile" pipfile_lock = workspace / "Pipfile.lock" if pipfile.exists(): if self.confirm("Do you wanna delete Pipfile?", False): os.remove(pipfile) self.info("Pipfile deleted!") if pipfile_lock.exists(): if self.confirm("Do you wanna delete Pipfile.lock?", False): os.remove(pipfile_lock) self.info("Pipfile.lock deleted!") application.add(GenerateCommand()) PK!s[PPpoetrify/core.pyimport licensename import tomlkit def generate_init_cmd(): """ :return: Generated command for 'poetry init' . :rtype: str """ try: with open("Pipfile") as f: d = tomlkit.parse(f.read()) except FileNotFoundError: return packages = list(d["packages"].keys()) dev_packages = list(d["dev-packages"].keys()) cmd = ["poetry", "init"] for package in packages: cmd.append(f"--dependency={package}") for package in dev_packages: cmd.append(f"--dev-dependency={package}") try: license_name = licensename.from_file("LICENSE") except FileNotFoundError: license_name = "" else: if license_name is None: license_name = "" if license_name: cmd.append(f"--license={license_name}") return " ".join(cmd) PK!H'=49)poetrify-0.2.1.dist-info/entry_points.txtN+I/N.,()*O-)L1s2 r2K2JPK!c+$$ poetrify-0.2.1.dist-info/LICENSEMIT License Copyright (c) 2019 kk6 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK!HڽTUpoetrify-0.2.1.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!H[^4C!poetrify-0.2.1.dist-info/METADATAMO1#H؛>FPQCk$kt}$(";{Qo胲&#d98ѫY˶HISҷ9)-y(5̬q:޲϶F.:=|;U yd&VX9R*子R0O!Qؚ}%D]^ +-CP3t5>Fael9 PJ32++kոܘMu /:3Wo;Gνkep'ͼ%k ɷlģuHť3ՀJOhhNU9-_^ř8:<')Zw_䩅w";M5+ɝF+udbF6]viuvLnfb[t:e{0х<(R5Oɋy6ۼAqu-(%` /!s2VYEpf(]_6&4-|kPQ.M+^_J붺z=RK8L;!S յ4%Oi lHZB٬Ezk2- PK!H nE5epoetrify-0.2.1.dist-info/RECORD}v0}ЀJH "ִ\" <̆9nty|sb<9z)DYp?iГm`H!NLfVcޱ(*kD1BB$!OA8a|vzԝ؍E+8©c-ο<Ï*yܽW-ǜtegvrEzPcx*;a i*ϠV]BN^7R`y(=ݿ*I.ҽ6h/I#!ߜFinf~nMڮqνgYmYFT>ƣ6\SLtCOٽ2P8x PR")jP%'\qoPK!Dpoetrify/__init__.pyPK!\Hpoetrify/cli.pyPK!s[PPapoetrify/core.pyPK!H'=49) poetrify-0.2.1.dist-info/entry_points.txtPK!c+$$ Z poetrify-0.2.1.dist-info/LICENSEPK!HڽTUpoetrify-0.2.1.dist-info/WHEELPK!H[^4C!Lpoetrify-0.2.1.dist-info/METADATAPK!H nE5epoetrify-0.2.1.dist-info/RECORDPKJ