tools/web: new option to remove callback from JSON files
This commit is contained in:
parent
89772ebce0
commit
1dae3c713a
@ -193,7 +193,7 @@ def getXML(*args, **kwargs):
|
|||||||
return parseString(cnt)
|
return parseString(cnt)
|
||||||
|
|
||||||
|
|
||||||
def getJSON(*args, **kwargs):
|
def getJSON(*args, remove_callback=False, **kwargs):
|
||||||
"""Get content page and return JSON content
|
"""Get content page and return JSON content
|
||||||
|
|
||||||
Arguments: same as getURLContent
|
Arguments: same as getURLContent
|
||||||
@ -204,6 +204,9 @@ def getJSON(*args, **kwargs):
|
|||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
import json
|
import json
|
||||||
|
if remove_callback:
|
||||||
|
import re
|
||||||
|
cnt = re.sub(r"^[^(]+\((.*)\)$", r"\1", cnt)
|
||||||
return json.loads(cnt)
|
return json.loads(cnt)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user