PyLD 2.0.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- PyLD-2.0.4.dist-info/LICENSE +44 -0
- PyLD-2.0.4.dist-info/METADATA +276 -0
- PyLD-2.0.4.dist-info/RECORD +16 -0
- PyLD-2.0.4.dist-info/WHEEL +5 -0
- PyLD-2.0.4.dist-info/top_level.txt +2 -0
- c14n/Canonicalize.py +474 -0
- c14n/NumberToJson.py +112 -0
- c14n/__init__.py +4 -0
- pyld/__about__.py +9 -0
- pyld/__init__.py +5 -0
- pyld/context_resolver.py +215 -0
- pyld/documentloader/__init__.py +0 -0
- pyld/documentloader/aiohttp.py +119 -0
- pyld/documentloader/requests.py +105 -0
- pyld/jsonld.py +6712 -0
- pyld/resolved_context.py +38 -0
pyld/resolved_context.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Representation for a resolved Context.
|
|
3
|
+
|
|
4
|
+
.. module:: resolved_context
|
|
5
|
+
:synopsis: Creates a ContextResolver
|
|
6
|
+
|
|
7
|
+
.. moduleauthor:: Dave Longley
|
|
8
|
+
.. moduleauthor:: Gregg Kellogg <gregg@greggkellogg.net>
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from cachetools import LRUCache
|
|
12
|
+
|
|
13
|
+
MAX_ACTIVE_CONTEXTS = 10
|
|
14
|
+
|
|
15
|
+
class ResolvedContext:
|
|
16
|
+
"""
|
|
17
|
+
A cached contex document, with a cache indexed by referencing active context.
|
|
18
|
+
"""
|
|
19
|
+
def __init__(self, document):
|
|
20
|
+
"""
|
|
21
|
+
Creates a ResolvedContext with caching for processed contexts
|
|
22
|
+
relative to some other Active Context.
|
|
23
|
+
"""
|
|
24
|
+
# processor-specific RDF parsers
|
|
25
|
+
self.document = document
|
|
26
|
+
self.cache = LRUCache(maxsize=MAX_ACTIVE_CONTEXTS)
|
|
27
|
+
|
|
28
|
+
def get_processed(self, active_ctx):
|
|
29
|
+
"""
|
|
30
|
+
Returns any processed context for this resolved context relative to an active context.
|
|
31
|
+
"""
|
|
32
|
+
return self.cache.get(active_ctx['_uuid'])
|
|
33
|
+
|
|
34
|
+
def set_processed(self, active_ctx, processed_ctx):
|
|
35
|
+
"""
|
|
36
|
+
Sets any processed context for this resolved context relative to an active context.
|
|
37
|
+
"""
|
|
38
|
+
self.cache[active_ctx['_uuid']] = processed_ctx
|