Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# Note: 

2# Try to avoid module level import statements here to reduce 

3# import time during CLI execution 

4 

5 

6class CLICommand: 

7 """Get calculations from NOMAD and write to JSON files. 

8 

9 ... 

10 """ 

11 

12 @staticmethod 

13 def add_arguments(p): 

14 p.add_argument('uri', nargs='+', metavar='nmd://<hash>', 

15 help='URIs to get') 

16 

17 @staticmethod 

18 def run(args): 

19 import json 

20 from ase.nomad import download 

21 for uri in args.uri: 

22 calculation = download(uri) 

23 identifier = calculation.hash.replace('/', '.') 

24 fname = 'nmd.{}.nomad-json'.format(identifier) 

25 with open(fname, 'w') as fd: 

26 json.dump(calculation, fd) 

27 print(uri)