mirror of https://gitlab.com/bashrc2/epicyon
Wildcard schemas
parent
0ec3e1ea72
commit
758747740e
20
context.py
20
context.py
|
@ -11,7 +11,7 @@ validContexts = (
|
||||||
"https://www.w3.org/ns/activitystreams",
|
"https://www.w3.org/ns/activitystreams",
|
||||||
"https://w3id.org/identity/v1",
|
"https://w3id.org/identity/v1",
|
||||||
"https://w3id.org/security/v1",
|
"https://w3id.org/security/v1",
|
||||||
"https://raitisoja.com/apschema/v1.21"
|
"*/apschema/v1.21"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,11 +25,27 @@ def hasValidContext(postJsonObject: {}) -> bool:
|
||||||
if not isinstance(url, str):
|
if not isinstance(url, str):
|
||||||
continue
|
continue
|
||||||
if url not in validContexts:
|
if url not in validContexts:
|
||||||
|
wildcardFound = False
|
||||||
|
for c in validContexts:
|
||||||
|
if c.startswith('*'):
|
||||||
|
c = c.replace('*', '')
|
||||||
|
if url.endswith(c):
|
||||||
|
wildcardFound = True
|
||||||
|
break
|
||||||
|
if not wildcardFound:
|
||||||
print('Unrecognized @context: ' + url)
|
print('Unrecognized @context: ' + url)
|
||||||
return False
|
return False
|
||||||
elif isinstance(postJsonObject['@context'], str):
|
elif isinstance(postJsonObject['@context'], str):
|
||||||
url = postJsonObject['@context']
|
url = postJsonObject['@context']
|
||||||
if url not in validContexts:
|
if url not in validContexts:
|
||||||
|
wildcardFound = False
|
||||||
|
for c in validContexts:
|
||||||
|
if c.startswith('*'):
|
||||||
|
c = c.replace('*', '')
|
||||||
|
if url.endswith(c):
|
||||||
|
wildcardFound = True
|
||||||
|
break
|
||||||
|
if not wildcardFound:
|
||||||
print('Unrecognized @context: ' + url)
|
print('Unrecognized @context: ' + url)
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
@ -39,7 +55,7 @@ def hasValidContext(postJsonObject: {}) -> bool:
|
||||||
|
|
||||||
|
|
||||||
def getApschemaV1_21() -> {}:
|
def getApschemaV1_21() -> {}:
|
||||||
# https://raitisoja.com/apschema/v1.21
|
# https://domain/apschema/v1.21
|
||||||
return {
|
return {
|
||||||
"@context": {
|
"@context": {
|
||||||
"zot": "https://raitisoja.com/apschema#",
|
"zot": "https://raitisoja.com/apschema#",
|
||||||
|
|
Loading…
Reference in New Issue