Coverage for /builds/ase/ase/ase/cli/ulm.py : 58.82%

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
6class CLICommand:
7 """Manipulate/show content of ulm-file.
9 The ULM file format is used for ASE's trajectory files,
10 for GPAW's gpw-files and other things.
12 Example (show first image of a trajectory file):
14 ase ulm abc.traj -n 0 -v
15 """
17 @staticmethod
18 def add_arguments(parser):
19 add = parser.add_argument
20 add('filename', help='Name of ULM-file.')
21 add('-n', '--index', type=int,
22 help='Show only one index. Default is to show all.')
23 add('-d', '--delete', metavar='key1,key2,...',
24 help='Remove key(s) from ULM-file.')
25 add('-v', '--verbose', action='store_true', help='More output.')
27 @staticmethod
28 def run(args):
29 import os
30 from ase.io.ulm import copy, print_ulm_info
32 if args.delete:
33 exclude = set('.' + key for key in args.delete.split(','))
34 copy(args.filename, args.filename + '.temp', exclude)
35 os.rename(args.filename + '.temp', args.filename)
36 else:
37 print_ulm_info(args.filename, args.index, verbose=args.verbose)