mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Merge pull request #5539 from pypa/bump-vendored-plette
vendor: bump plette to 0.4.4
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Bump plette version to 0.4.4
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@ __all__ = [
|
||||
"Lockfile", "Pipfile",
|
||||
]
|
||||
|
||||
__version__ = '0.4.2'
|
||||
__version__ = '0.4.4'
|
||||
|
||||
from .lockfiles import Lockfile
|
||||
from .pipfiles import Pipfile
|
||||
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
"""
|
||||
A simple entry point which can be use to test Pipfiles
|
||||
|
||||
e.g.
|
||||
|
||||
python -m plette -f examples/Pipfile.valid.list
|
||||
python -m plette -f examples/Pipfile.valid.editable
|
||||
# throws exception
|
||||
python -m plette -f examples/Pipfile.invalid.list
|
||||
|
||||
"""
|
||||
from pipenv.vendor.plette import Pipfile
|
||||
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-f", "--file", help="Input file")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
dest = args.file
|
||||
|
||||
with open(dest) as f:
|
||||
pipfile = Pipfile.load(f)
|
||||
+7
-1
@@ -16,5 +16,11 @@ from .scripts import Script
|
||||
from .sources import Source
|
||||
|
||||
from .sections import (
|
||||
Meta, Requires, PackageCollection, ScriptCollection, SourceCollection,
|
||||
Meta,
|
||||
Requires,
|
||||
PackageCollection,
|
||||
Pipenv,
|
||||
PipfileSection,
|
||||
ScriptCollection,
|
||||
SourceCollection,
|
||||
)
|
||||
|
||||
+16
-1
@@ -21,7 +21,9 @@ class Package(DataView):
|
||||
def validate(cls, data):
|
||||
# HACK: Make this validatable for Cerberus. See comments in validation
|
||||
# side for more information.
|
||||
return super(Package, cls).validate({"__package__": data})
|
||||
super(Package, cls).validate({"__package__": data})
|
||||
if isinstance(data, dict):
|
||||
PackageSpecfiers.validate({"__specifiers__": data})
|
||||
|
||||
def __getattr__(self, key):
|
||||
if isinstance(self._data, str):
|
||||
@@ -41,3 +43,16 @@ class Package(DataView):
|
||||
self._data = value
|
||||
else:
|
||||
self._data[key] = value
|
||||
|
||||
class PackageSpecfiers(DataView):
|
||||
# TODO: one could add here more validation for path editable
|
||||
# and more stuff which is currently allowed and undocumented
|
||||
__SCHEMA__ = {
|
||||
"__specifiers__": {
|
||||
"type": "dict",
|
||||
"schema":{
|
||||
"version": {"type": "string"},
|
||||
"extras": {"type": "list"},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -50,6 +50,16 @@ META_SECTIONS = {
|
||||
"sources": SourceCollection,
|
||||
}
|
||||
|
||||
class PipfileSection(DataView):
|
||||
|
||||
"""
|
||||
Dummy pipfile validator that needs to be completed in a future PR
|
||||
Hint: many pipfile features are undocumented in pipenv/project.py
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def validate(cls, data):
|
||||
pass
|
||||
|
||||
class Meta(DataView):
|
||||
"""Representation of the `_meta` section in a Pipfile.lock."""
|
||||
@@ -119,3 +129,11 @@ class Meta(DataView):
|
||||
@sources.setter
|
||||
def sources(self, value):
|
||||
self["sources"] = value
|
||||
|
||||
|
||||
class Pipenv(DataView):
|
||||
"""Represent the [pipenv] section in Pipfile"""
|
||||
|
||||
__SCHEMA__ = {
|
||||
"allow_prereleases": {"type": "boolean", "required": False},
|
||||
}
|
||||
|
||||
Vendored
+8
-2
@@ -4,7 +4,7 @@ import json
|
||||
import pipenv.vendor.tomlkit as tomlkit
|
||||
|
||||
from .models import (
|
||||
DataView, Hash, Requires,
|
||||
DataView, Hash, Requires, PipfileSection, Pipenv,
|
||||
PackageCollection, ScriptCollection, SourceCollection,
|
||||
)
|
||||
|
||||
@@ -15,6 +15,8 @@ PIPFILE_SECTIONS = {
|
||||
"dev-packages": PackageCollection,
|
||||
"requires": Requires,
|
||||
"scripts": ScriptCollection,
|
||||
"pipfile": PipfileSection,
|
||||
"pipenv": Pipenv
|
||||
}
|
||||
|
||||
DEFAULT_SOURCE_TOML = """\
|
||||
@@ -24,7 +26,6 @@ url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
"""
|
||||
|
||||
|
||||
class Pipfile(DataView):
|
||||
"""Representation of a Pipfile.
|
||||
"""
|
||||
@@ -42,6 +43,11 @@ class Pipfile(DataView):
|
||||
continue
|
||||
klass.validate(data[key])
|
||||
|
||||
package_categories = set(data.keys()) - set(PIPFILE_SECTIONS.keys())
|
||||
|
||||
for category in package_categories:
|
||||
PackageCollection.validate(data[category])
|
||||
|
||||
@classmethod
|
||||
def load(cls, f, encoding=None):
|
||||
content = f.read()
|
||||
|
||||
Vendored
+1
-1
@@ -7,7 +7,7 @@ dparse==0.6.2
|
||||
markupsafe==2.0.1
|
||||
pexpect==4.8.0
|
||||
pipdeptree==2.3.1
|
||||
plette[validation]==0.4.2
|
||||
plette[validation]==0.4.4
|
||||
ptyprocess==0.7.0
|
||||
pyparsing==3.0.9
|
||||
python-dotenv==0.19.0
|
||||
|
||||
Reference in New Issue
Block a user