Skip to content

frozendict → immutabledict (as frozendict is unmaintained) #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
14 changes: 7 additions & 7 deletions lib/pyld/context_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
.. moduleauthor:: Gregg Kellogg <[email protected]>
"""

from frozendict import frozendict
from immutabledict import immutabledict
from c14n.Canonicalize import canonicalize
from pyld import jsonld
from .resolved_context import ResolvedContext
Expand Down Expand Up @@ -42,7 +42,7 @@ def resolve(self, active_ctx, context, base, cycles=None):
cycles = set()

# process `@context`
if (isinstance(context, dict) or isinstance(context, frozendict)) and '@context' in context:
if (isinstance(context, dict) or isinstance(context, immutabledict)) and '@context' in context:
context = context['@context']

# context is one or more contexts
Expand All @@ -65,7 +65,7 @@ def resolve(self, active_ctx, context, base, cycles=None):
all_resolved.append(resolved)
elif not ctx:
all_resolved.append(ResolvedContext(False))
elif not isinstance(ctx, dict) and not isinstance(ctx, frozendict):
elif not isinstance(ctx, dict) and not isinstance(ctx, immutabledict):
raise jsonld.JsonLdError(
'Invalid JSON-LD syntax; @context must be an object.',
'jsonld.SyntaxError', {'context': ctx},
Expand Down Expand Up @@ -157,7 +157,7 @@ def _fetch_context(self, active_ctx, url, cycles):
code='loading remote context failed')

# ensure ctx is an object
if not isinstance(context, dict) and not isinstance(context, frozendict):
if not isinstance(context, dict) and not isinstance(context, immutabledict):
raise jsonld.JsonLdError(
'Dereferencing a URL did not result in a JSON object. The ' +
'response was valid JSON, but it was not a JSON object.',
Expand Down Expand Up @@ -188,7 +188,7 @@ def _resolve_context_urls(self, context, base):
:param context: the context.
:param base: the base IRI to use to resolve relative IRIs.
"""
if not isinstance(context, dict) and not isinstance(context, frozendict):
if not isinstance(context, dict) and not isinstance(context, immutabledict):
return

ctx = context.get('@context')
Expand All @@ -201,11 +201,11 @@ def _resolve_context_urls(self, context, base):
for num, element in enumerate(ctx):
if isinstance(element, str):
ctx[num] = jsonld.prepend_base(base, element)
elif isinstance(element, dict) or isinstance(element, frozendict):
elif isinstance(element, dict) or isinstance(element, immutabledict):
self. _resolve_context_urls({'@context': element}, base)
return

if not isinstance(ctx, dict) and not isinstance(ctx, frozendict):
if not isinstance(ctx, dict) and not isinstance(ctx, immutabledict):
# no @context URLs can be found in non-object
return

Expand Down
6 changes: 3 additions & 3 deletions lib/pyld/jsonld.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from functools import cmp_to_key
import lxml.html
from numbers import Integral, Real
from frozendict import frozendict
from immutabledict import immutabledict
from pyld.__about__ import (__copyright__, __license__, __version__)

def cmp(a, b):
Expand Down Expand Up @@ -6295,7 +6295,7 @@ def _is_object(v):

:return: True if the value is an Object, False if not.
"""
return isinstance(v, dict) or isinstance(v, frozendict)
return isinstance(v, dict) or isinstance(v, immutabledict)


def _is_empty_object(v):
Expand Down Expand Up @@ -6539,7 +6539,7 @@ def _is_relative_iri(v):

def freeze(value):
if isinstance(value, dict):
return frozendict(dict([(k, v) for (k, v) in value.items()]))
return immutabledict(dict([(k, v) for (k, v) in value.items()]))
return value

# The default JSON-LD document loader.
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ requests
aiohttp; python_version >= '3.5'
lxml
cachetools
frozendict
immutabledict
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@
],
install_requires=[
'cachetools',
'frozendict',
'immutabledict',
'lxml',
],
extras_require={
'requests': ['requests'],
'aiohttp': ['aiohttp'],
'cachetools': ['cachetools'],
'frozendict': ['frozendict'],
'immutabledict': ['immutabledict'],
}
)