Skip to content

Commit

Permalink
Merge branch 'develop' of ssh://git.ecmwf.int/mag/magics into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvielamythepaut committed Sep 3, 2020
2 parents ace1de1 + 235a3d3 commit 003bc47
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
63 changes: 63 additions & 0 deletions tools/xref.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 003bc47

Please sign in to comment.