Closed rmax closed 7 years ago
Here is an usage example:
>>> import js2xml_utils
>>> code = """
...: var FOO['bar'] = [{}, {a: true}];
...: var FOO['baz'] = null;
...: """
>>> js2xml_utils.get_vars(code)
{'FOO[bar]': [{}, {'a': True}], 'FOO[baz]': None}
>>> js2xml_utils.get_vars(code)['FOO[bar]']
[{}, {'a': True}]
Probably we could start a new project js2dict
that depends on js2xml
and converts the js code into a lookable dictionary.
I while ago I made this
get_vars(snippet)
helper on top ofjs2xml
: https://gist.github.com/rolando/c7ad34cf1f70d114ec64b072581fb1f9Which is helpful to turn a JS snippet into a python object where you can access JS variables by name and get the parsed values.
Is this a good addition to
js2xml
?There are open question, like how to transform anonymous functions
var myfunc = function() { var foo = "bar"; }
so that you can access tofoo
value.