mirror of https://gitlab.com/bashrc2/epicyon
Wildcard schemas
parent
0ec3e1ea72
commit
758747740e
28
context.py
28
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,13 +25,29 @@ 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:
|
||||||
print('Unrecognized @context: ' + url)
|
wildcardFound = False
|
||||||
return 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)
|
||||||
|
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:
|
||||||
print('Unrecognized @context: ' + url)
|
wildcardFound = False
|
||||||
return 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)
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
# not a list or string
|
# not a list or string
|
||||||
return False
|
return False
|
||||||
|
@ -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