PK!c>""jetty/__init__.pyfrom jetty.project import Project PK!jetty/__version__.py__version__ = "0.1.0" PK!8jetty/cli/__init__.pyimport sys from jetty.cli.application import Application def run(): Application().run() if __name__ == '__main__': sys.exit(run()) PK!X4jetty/cli/application.pyimport os from cleo import Application as BaseApplication from cleo.formatters import Formatter from poetry.console.application import Application as PoetryApplication from poetry.console.commands import ( AddCommand, InstallCommand, LockCommand, ShowCommand, UpdateCommand, ) from jetty.__version__ import __version__ from jetty.project import JettisonedPoetry class Application(PoetryApplication): def __init__(self): BaseApplication.__init__(self, "Jetty", __version__) self._poetry = None self._skip_io_configuration = False self._formatter = Formatter(True) self._formatter.add_style("error", "red", options=["bold"]) @property def poetry(self): if self._poetry: return self._poetry self._poetry = JettisonedPoetry.create() return self._poetry def get_default_commands(self): commands = BaseApplication.get_default_commands(self) commands += [ AddCommand(), InstallCommand(), LockCommand(), ShowCommand(), UpdateCommand(), ] return commands PK!q͆jetty/project.pyimport os from cleo.inputs import ArgvInput from poetry import json from poetry.packages import ( Locker, ProjectPackage, ) from poetry.poetry import Poetry from poetry.utils._compat import Path from poetry.utils.toml_file import TomlFile from jetty.util.dicttools import merge here = Path(__file__).parent.resolve() class Project: def __init__(self, path=None): from jetty.cli import Application self._poetry = JettisonedPoetry.create(path) self._application = Application() self._application._auto_exit = False self._application._poetry = self._poetry for name, command in self._application.all().items(): func = self._make_func(name, command) func.__doc__ = command.__doc__ setattr(self, name, func.__get__(self)) def _make_func(self, name, command): definition = command.get_definition() args = [] kwargs = [] for arg in definition.get_arguments() + definition.get_options(): if hasattr(arg, 'is_required') and arg.is_required(): args.append(arg.get_name()) continue arg_name = arg.get_name().replace("-", "_") arg_default = arg.get_default() if isinstance(arg_default, str): arg_default = f"\"{arg_default}\"" kwargs.append(f"{arg_name}={arg_default}") args = ", ".join(args) if args: args = ", " + args kwargs = ", ".join(kwargs) if kwargs: kwargs = ", " + kwargs exec(f""" def {name}(self{args}{kwargs}): kwargs = locals().copy() del kwargs["self"] cmd = self._build_cmd("{name}", **kwargs) self._run(["{name}"] + cmd) """.strip()) return locals()[name] def _build_cmd(self, name, **kwargs): definition = self._application.all()[name].get_definition() cmd = [] for name, value in kwargs.items(): name = name.replace("_", "-") if definition.has_argument(name): arg = definition.get_argument(name) if value != arg.get_default(): cmd.append(value) elif definition.has_option(name): opt = definition.get_option(name) if value != opt.get_default(): if isinstance(value, bool): cmd.append(f"--{name}") else: cmd.append(f"--{name}={value}") return cmd def _run(self, cmd): i = ArgvInput(["poetry -v"] + cmd) self._application.run(i) class JettisonedPoetry(Poetry): @classmethod def create(cls, path=None): path = path or os.getcwd() pyproject_file = Path(path) if pyproject_file.name != "pyproject.toml": pyproject_file = pyproject_file / "pyproject.toml" if not pyproject_file.exists(): raise RuntimeError( "Jetty could not find a pyproject.toml file in {}".format( path ) ) local_config = TomlFile(pyproject_file.as_posix()).read() tool = local_config.setdefault('tool', {}) if 'jetty' not in tool and 'poetry' not in tool: raise RuntimeError("[tool.jetty] section not found in {}" .format(pyproject_file.name)) local_config = merge(tool.get('jetty', {}), tool.get('poetry', {})) # Checking validity cls.check(local_config) # Load package name = local_config.get('name', pyproject_file.parent.name) version = local_config.get('version', '0') package = ProjectPackage(name, version, version) if 'dependencies' in local_config: for name, constraint in local_config['dependencies'].items(): if name.lower() == 'python': package.python_versions = constraint continue if isinstance(constraint, list): for _constraint in constraint: package.add_dependency(name, _constraint) continue package.add_dependency(name, constraint) if 'dev-dependencies' in local_config: for name, constraint in local_config['dev-dependencies'].items(): if isinstance(constraint, list): for _constraint in constraint: package.add_dependency(name, _constraint, category='dev') continue package.add_dependency(name, constraint, category='dev') extras = local_config.get("extras", {}) for extra_name, requirements in extras.items(): package.extras[extra_name] = [] # Checking for dependency for req in requirements: req = Dependency(req, "*") for dep in package.requires: if dep.name == req.name: dep.in_extras.append(extra_name) package.extras[extra_name].append(dep) break lock = pyproject_file.parent / "poetry.lock" locker = Locker(lock, local_config) return cls(pyproject_file, local_config, package, locker) @classmethod def check(cls, config, strict=False): json.SCHEMA_DIR = here / "schemas" return Poetry.check(config, strict=strict) PK!uB8B8 jetty/schemas/poetry-schema.json{ "$schema": "http://json-schema.org/draft-04/schema#", "name": "Package", "type": "object", "additionalProperties": false, "properties": { "name": { "type": "string", "description": "Package name." }, "version": { "type": "string", "description": "Package version." }, "description": { "type": "string", "description": "Short package description." }, "keywords": { "type": "array", "items": { "type": "string", "description": "A tag/keyword that this package relates to." } }, "homepage": { "type": "string", "description": "Homepage URL for the project.", "format": "uri" }, "repository": { "type": "string", "description": "Repository URL for the project.", "format": "uri" }, "documentation": { "type": "string", "description": "Documentation URL for the project.", "format": "uri" }, "license": { "type": "string", "description": "License name." }, "authors": { "$ref": "#/definitions/authors" }, "readme": { "type": "string", "description": "The path to the README file" }, "classifiers": { "type": "array", "description": "A list of trove classifers." }, "packages": { "type": "array", "description": "A list of packages to include in the final distribution.", "items": { "type": "object", "description": "Information about where the package resides.", "additionalProperties": false, "required": [ "include" ], "properties": { "include": { "type": "string", "description": "What to include in the package." }, "from": { "type": "string", "description": "Where the source directory of the package resides." } } } }, "include": { "type": "array", "description": "A list of files and folders to include." }, "exclude": { "type": "array", "description": "A list of files and folders to exclude." }, "dependencies": { "type": "object", "description": "This is a hash of package name (keys) and version constraints (values) that are required to run this package.", "required": [ "python" ], "properties": { "python": { "type": "string", "description": "The Python versions the package is compatible with." } }, "$ref": "#/definitions/dependencies", "additionalProperties": false }, "dev-dependencies": { "type": "object", "description": "This is a hash of package name (keys) and version constraints (values) that this package requires for developing it (testing tools and such).", "$ref": "#/definitions/dependencies", "additionalProperties": false }, "extras": { "type": "object", "patternProperties": { "^[a-zA-Z-_.0-9]+$": { "type": "array", "items": { "type": "string" } } } }, "build": { "type": "string", "description": "The file used to build extensions." }, "source": { "type": "array", "description": "A set of additional repositories where packages can be found.", "additionalProperties": { "$ref": "#/definitions/repository" }, "items": { "$ref": "#/definitions/repository" } }, "scripts": { "type": "object", "description": "A hash of scripts to be installed.", "items": { "type": "string" } }, "plugins": { "type": "object", "description": "A hash of hashes representing plugins", "patternProperties": { "^[a-zA-Z-_.0-9]+$": { "type": "object", "patternProperties": { "^[a-zA-Z-_.0-9]+$": { "type": "string" } } } } } }, "definitions": { "authors": { "type": "array", "description": "List of authors that contributed to the package. This is typically the main maintainers, not the full list.", "items": { "type": "string" } }, "dependencies": { "type": "object", "patternProperties": { "^[a-zA-Z-_.0-9]+$": { "oneOf": [ { "$ref": "#/definitions/dependency" }, { "$ref": "#/definitions/long-dependency" }, { "$ref": "#/definitions/git-dependency" }, { "$ref": "#/definitions/file-dependency" }, { "$ref": "#/definitions/path-dependency" }, { "$ref": "#/definitions/multiple-constraints-dependency" } ] } } }, "dependency": { "type": "string", "description": "The constraint of the dependency." }, "long-dependency": { "type": "object", "required": [ "version" ], "additionalProperties": false, "properties": { "version": { "type": "string", "description": "The constraint of the dependency." }, "python": { "type": "string", "description": "The python versions for which the dependency should be installed." }, "platform": { "type": "string", "description": "The platform(s) for which the dependency should be installed." }, "allows-prereleases": { "type": "boolean", "description": "Whether the dependency allows prereleases or not." }, "optional": { "type": "boolean", "description": "Whether the dependency is optional or not." }, "extras": { "type": "array", "description": "The required extras for this dependency.", "items": { "type": "string" } } } }, "git-dependency": { "type": "object", "required": [ "git" ], "additionalProperties": false, "properties": { "git": { "type": "string", "description": "The url of the git repository.", "format": "uri" }, "branch": { "type": "string", "description": "The branch to checkout." }, "tag": { "type": "string", "description": "The tag to checkout." }, "rev": { "type": "string", "description": "The revision to checkout." }, "python": { "type": "string", "description": "The python versions for which the dependency should be installed." }, "platform": { "type": "string", "description": "The platform(s) for which the dependency should be installed." }, "allows-prereleases": { "type": "boolean", "description": "Whether the dependency allows prereleases or not." }, "optional": { "type": "boolean", "description": "Whether the dependency is optional or not." }, "extras": { "type": "array", "description": "The required extras for this dependency.", "items": { "type": "string" } } } }, "file-dependency": { "type": "object", "required": [ "file" ], "additionalProperties": false, "properties": { "file": { "type": "string", "description": "The path to the file." }, "python": { "type": "string", "description": "The python versions for which the dependency should be installed." }, "platform": { "type": "string", "description": "The platform(s) for which the dependency should be installed." }, "optional": { "type": "boolean", "description": "Whether the dependency is optional or not." }, "extras": { "type": "array", "description": "The required extras for this dependency.", "items": { "type": "string" } } } }, "path-dependency": { "type": "object", "required": [ "path" ], "additionalProperties": false, "properties": { "path": { "type": "string", "description": "The path to the dependency." }, "python": { "type": "string", "description": "The python versions for which the dependency should be installed." }, "platform": { "type": "string", "description": "The platform(s) for which the dependency should be installed." }, "optional": { "type": "boolean", "description": "Whether the dependency is optional or not." }, "extras": { "type": "array", "description": "The required extras for this dependency.", "items": { "type": "string" } }, "develop": { "type": "boolean", "description": "Whether to install the dependency in development mode." } } }, "multiple-constraints-dependency": { "type": "array", "minItems": 1, "items": { "oneOf": [ { "$ref": "#/definitions/dependency" }, { "$ref": "#/definitions/long-dependency" }, { "$ref": "#/definitions/git-dependency" }, { "$ref": "#/definitions/file-dependency" }, { "$ref": "#/definitions/path-dependency" } ] } }, "scripts": { "type": "object", "patternProperties": { "^[a-zA-Z-_.0-9]+$": { "oneOf": [ { "$ref": "#/definitions/script" }, { "$ref": "#/definitions/extra-script" } ] } } }, "script": { "type": "string", "description": "A simple script pointing to a callable object." }, "extra-script": { "type": "object", "description": "A script that should be installed only if extras are activated.", "properties": { "callable": { "$ref": "#/definitions/script" }, "extras": { "type": "array", "description": "The required extras for this script.", "items": { "type": "string" } } } }, "repository": { "type": "object", "properties": { "name": { "type": "string", "description": "The name of the repository" }, "url": { "type": "string", "description": "The url of the repository", "format": "uri" } } } } } PK!jetty/util/dicttools.pydef merge(source, dest): """ Merge dict and arrays (override scalar values). Keys from source override keys from dest, and elements from lists in source are appended to lists in dest. Args: source (dict): to copy from dest (dict): to copy to (modified in place) """ for key, value in source.items(): if key not in dest: dest[key] = value continue # Merge dict if isinstance(value, dict) and isinstance(dest[key], dict): merge(value, dest[key]) continue if isinstance(value, list) and isinstance(dest[key], list): dest[key] = dest[key] + value continue dest[key] = value return dest PK!HS%'&jetty-0.1.0.dist-info/entry_points.txtN+I/N.,()J-)z9VEy\\PK!H|n-WYjetty-0.1.0.dist-info/WHEEL A н#Z;/" bFF]xzwK;<*mTֻ0*Ri.4Vm0[H, JPK!Hjetty-0.1.0.dist-info/METADATAOO0 R&*8 upMSoOn ޞs,Ɋ{$H]q1`Pᕬw}iZW‘]zY&T5\g^贵{m8',DƹH{hy,9(j=P;G,Nf8DpQD8aץh"Eva/fmtaR* UѺ!WXh,юx#9܍l,mIN3cwKB&k z0!V围:ŨPK!H+9!Gjetty-0.1.0.dist-info/RECORDuɒ@}= ( S!M@H!2ŽZuc8MWA_Mʹ*v34R窺d\˽νFwR eZ[ўXHf,~CʱsM:0TelqN ,d]UoMC@)q/XP ֽxRw7ӱAi&'lPĥ/ml4DC_9~R`}nu[1kDJ]w9#V1 _gozq/N4ƭ T fE-BmS ~4u~:Uyōc8LI9WfHuQ+F;.&DGM'jFM<ؚ龙,uYqSeNH!Rj@#?PK!c>""jetty/__init__.pyPK!Qjetty/__version__.pyPK!8jetty/cli/__init__.pyPK!X4\jetty/cli/application.pyPK!q͆jetty/project.pyPK!uB8B8 jetty/schemas/poetry-schema.jsonPK!NTjetty/util/dicttools.pyPK!HS%'&pWjetty-0.1.0.dist-info/entry_points.txtPK!H|n-WYWjetty-0.1.0.dist-info/WHEELPK!HiXjetty-0.1.0.dist-info/METADATAPK!H+9!GYjetty-0.1.0.dist-info/RECORDPK \