PK!U]O**jetty/__init__.pyfrom jetty.project import Project # noqa PK!$jetty/__version__.py__version__ = "0.1.1" PK!8jetty/cli/__init__.pyimport sys from jetty.cli.application import Application def run(): Application().run() if __name__ == '__main__': sys.exit(run()) PK!x}}jetty/cli/application.pyfrom 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!;]Xjetty/project.pyfrom __future__ import absolute_import import os from cleo.inputs import ArgvInput from poetry import json from poetry.packages import ( Dependency, 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(): arg_name = arg.get_name().replace("-", "_") if hasattr(arg, 'is_required') and arg.is_required(): args.append(arg_name) continue arg_default = arg.get_default() if isinstance(arg_default, str): arg_default = "\"{}\"".format(arg_default) kwargs.append("{}={}".format(arg_name, arg_default)) args = ", ".join(args) if args: args = ", " + args kwargs = ", ".join(kwargs) if kwargs: kwargs = ", " + kwargs exec(""" def {name}(self{args}{kwargs}): kwargs = locals().copy() del kwargs["self"] cmd = self._build_cmd("{name}", **kwargs) self._run(["{name}"] + cmd) """.strip().format(name=name, args=args, kwargs=kwargs)) 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("--{}".format(name)) else: cmd.append("--{}={}".format(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.2.dist-info/entry_points.txtN+I/N.,()J-)z9VEy\\PK!H|n-WYjetty-0.1.2.dist-info/WHEEL A н#Z;/" bFF]xzwK;<*mTֻ0*Ri.4Vm0[H, JPK!HeF"jetty-0.1.2.dist-info/METADATAOO0 R&*8 up6MSoOn ޞs,-zd+CX%k;!mZtVX8!WO9䖪 gikV;C|"BY {,j=P;G,䜟"a2(£`®Kl"EvB斧um~1k JɪVE^^cyHF:<\vLG;юp7oKt>!v!/Tk}jUI;Sz0/PK!H^ Gjetty-0.1.2.dist-info/RECORDuKs@}~ (X†jHB%~25ʩ,;bl9Đ\߀uاGjNW N P;j^]M|IHkNZozH?T' Fapy0'LuqJb/+ݍ.q4`\>aˣ>ǎ~7wΉJ[XUyZV!oGC|ry4kpekQ' Ҏ`Ob-VqvR{m̫(:!3#_KISRn3<|;o0ZU8$>=߲T{!#xgbaz`;/a!mTZl nOup ECdU8Sż0gY {C\yzsJ f=ؤ7mnBqt$tx*CqBLןmY$Z jl Yߥe%C j_ jv"#}Bœ]H aUYd^JMk5"(?&ǽPK!U]O**jetty/__init__.pyPK!$Yjetty/__version__.pyPK!8jetty/cli/__init__.pyPK!x}}djetty/cli/application.pyPK!;]Xjetty/project.pyPK!uB8B8 Mjetty/schemas/poetry-schema.jsonPK!Tjetty/util/dicttools.pyPK!HS%'&Wjetty-0.1.2.dist-info/entry_points.txtPK!H|n-WYXXjetty-0.1.2.dist-info/WHEELPK!HeF"Xjetty-0.1.2.dist-info/METADATAPK!H^ GBZjetty-0.1.2.dist-info/RECORDPK \