Coverage for /builds/kinetik161/ase/ase/cli/ulm.py: 58.82%
17 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-12-10 11:04 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-12-10 11:04 +0000
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
31 from ase.io.ulm import copy, print_ulm_info
33 if args.delete:
34 exclude = {'.' + key for key in args.delete.split(',')}
35 copy(args.filename, args.filename + '.temp', exclude)
36 os.rename(args.filename + '.temp', args.filename)
37 else:
38 print_ulm_info(args.filename, args.index, verbose=args.verbose)