diff --git a/README.md b/README.md index 4b3c25c16..7bf8ec73e 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Python Package: Pypi or conda Gallery of Notebooks -------------------- -[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ecmwf/notebook-examples.git/master) +[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ecmwf/notebook-examples/master?filepath=%2Fhome%2Fjovyan%2Fvisualisation) Docker Image diff --git a/tools/xref.py b/tools/xref.py new file mode 100755 index 000000000..72aaaea35 --- /dev/null +++ b/tools/xref.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +import os +import xmltodict +import json +from collections import defaultdict + +DEFS = {} + + +def load(n): + with open(n) as f: + x = xmltodict.parse(f.read()) + + klass = x['magics']['class'] + klass['PATH'] = n + + assert klass['@name'] not in DEFS, (klass['@name'], n, DEFS[klass['@name']]) + DEFS[klass['@name']] = klass + + # if '@inherits' in klass: + # return + + # try: + # assert False + # print(klass['@name']) + # except: + # print(json.dumps(x, indent=4)) + # exit(1) + + +for n in sorted(os.listdir('.')): + if n.endswith('.xml'): # and n.startswith("SimpleP"): + load(n) + + +def action(klass): + if '@action' in klass: + return klass['@action'] + if '@inherits' in klass: + if '/' in klass['@inherits']: + return [action(x) for x in klass['@inherits'].split('/')] + return action(DEFS[klass['@inherits']]) + + +PARAMS = defaultdict(set) +for n, klass in DEFS.items(): + parms = klass.get('parameter', []) + if not isinstance(parms, list): + parms = [parms] + for p in parms: + + try: + PARAMS[p['@name']].add(action(klass)) + except: + print(klass) + raise + # print(n, action(klass)) + # if '@action' in klass: + # print(n, json.dumps(klass, indent=4)) +# load("Contour.xml") + +for p, v in sorted(PARAMS.items()): + print(p, v)