Browse Source

update deserialize implementations

master
Niklas Rosenstein 1 year ago
parent
commit
793c422b55
Signed by: NiklasRosenstein GPG Key ID: 06D269B33D25F6C6
2 changed files with 7 additions and 7 deletions
  1. + 1
    - 1
      src/shore/mapper.py
  2. + 6
    - 6
      src/shore/model.py

+ 1
- 1
src/shore/mapper.py

@ -24,4 +24,4 @@ from nr.databind.json import JsonModule
from shore.util.version import parse_version, Version
mapper = ObjectMapper(JsonModule())
mapper.register(Version, IDeserializer(lambda _m, _c, n: parse_version(n.value)))
mapper.register(Version, IDeserializer(lambda _m, n: parse_version(n.value)))

+ 6
- 6
src/shore/model.py

@ -134,7 +134,7 @@ class Requirement(object):
return '{} {}'.format(self.package, self.version.to_setuptools())
@classmethod
def _deserialize(cls, mapper, context, node):
def _deserialize(cls, mapper, node):
if not isinstance(node.value, str):
raise node.type_error()
return Requirement.parse(node.value)
@ -192,7 +192,7 @@ class Requirements(object):
return bool(self.python or self.required or self.platforms)
@classmethod
def _deserialize(cls, mapper, context, node):
def _deserialize(cls, mapper, node):
deserialize_type = [(Requirement, dict)]
items = mapper.deserialize_node(node.replace(datatype=deserialize_type))
@ -252,7 +252,7 @@ class Author(Struct):
return '{} <{}>'.format(self.name, self.email)
@classmethod
def _deserialize(cls, mapper, context, node):
def _deserialize(cls, mapper, node):
if isinstance(node.value, str):
match = Author.AUTHOR_EMAIL_REGEX.match(node.value)
if match:
@ -274,7 +274,7 @@ class Datafile(Struct):
exclude = Field([str])
@classmethod
def _deserialize(cls, mapper, context, node):
def _deserialize(cls, mapper, node):
if isinstance(node.value, str):
left, patterns = node.value.partition(',')[::2]
if ':' in left:
@ -349,7 +349,7 @@ class PluginConfig(Struct):
return ()
@classmethod
def _deserialize(cls, mapper, context, node):
def _deserialize(cls, mapper, node):
if isinstance(node.value, str):
plugin_name = node.value
config = {}
@ -383,7 +383,7 @@ class InstallHook(JsonMixin, Struct):
return self
@classmethod
def _deserialize(cls, mapper, context, node):
def _deserialize(cls, mapper, node):
if isinstance(node.value, str):
return InstallHook(None, node.value)
elif isinstance(node.value, dict):

Loading…
Cancel
Save