Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Replace deprecated validictory with fastest fastjsonschema module #656

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions gmusicapi/protocol/mobileclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""Calls made by the mobile client."""
from __future__ import print_function, division, absolute_import, unicode_literals
from six import raise_from
from builtins import * # noqa

import base64
import calendar
Expand All @@ -15,7 +14,7 @@
import time
from uuid import uuid1

import validictory
import fastjsonschema

import json
from gmusicapi.exceptions import ValidationException, CallFailure
Expand Down Expand Up @@ -662,14 +661,14 @@ class McCall(Call):

required_auth = authtypes(gpsoauth=True)

# validictory schema for the response
# Schema for the response
_res_schema = utils.NotImplementedField

@classmethod
def validate(cls, response, msg):
"""Use validictory and a static schema (stored in cls._res_schema)."""
"""Use fastjsonschema and a static schema (stored in cls._res_schema)."""
try:
return validictory.validate(msg, cls._res_schema)
return fastjsonschema.validate(msg, cls._res_schema)
except ValueError as e:
raise_from(ValidationException(str(e)), e)

Expand Down
9 changes: 4 additions & 5 deletions gmusicapi/protocol/webclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""Calls made by the web client."""
from __future__ import print_function, division, absolute_import, unicode_literals
from six import raise_from
from builtins import * # noqa

import base64
import copy
Expand All @@ -12,7 +11,7 @@
import string
from hashlib import sha1

import validictory
import fastjsonschema

import json
from gmusicapi.exceptions import CallFailure, ValidationException
Expand Down Expand Up @@ -57,14 +56,14 @@ class WcCall(Call):

required_auth = authtypes(xt=True, sso=True)

# validictory schema for the response
# Schema for the response
_res_schema = utils.NotImplementedField

@classmethod
def validate(cls, response, msg):
"""Use validictory and a static schema (stored in cls._res_schema)."""
"""Use fastjsonschema and a static schema (stored in cls._res_schema)."""
try:
return validictory.validate(msg, cls._res_schema)
return fastjsonschema.validate(msg, cls._res_schema)
except ValueError as e:
raise_from(ValidationException(str(e)), e)

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ python-dateutil==2.5.3
requests==2.20.0
rsa==3.4.2
six==1.10.0
validictory==1.0.2
fastjsonschema==2.14.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
long_description=(open('README.rst').read() + '\n\n' +
open('HISTORY.rst').read()),
install_requires=[
'validictory >= 0.8.0, != 0.9.2', # error messages
'fastjsonschema >= 2.14.1', # error messages
'decorator >= 3.3.1', # > 3.0 likely work, but not on pypi
'mutagen >= 1.34', # EasyID3 TPE2 mapping to albumartist
('requests >= 1.1.0, != 1.2.0,' # session.close, memory view TypeError
Expand Down