tools/web: new option to remove callback from JSON files

This commit is contained in:
nemunaire 2017-08-25 23:53:10 +02:00
parent 89772ebce0
commit 1dae3c713a

View File

@ -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)