44UNNAMED_SECTIONS = ['steps' , 'movechanges' , 'samplesets' , 'trajectories' ,
55 'snapshots' ]
66
7+ NAME_TO_ATTR = {
8+ 'CVs' : 'cvs' ,
9+ 'Volumes' : 'volumes' ,
10+ 'Engines' : 'engines' ,
11+ 'Networks' : 'networks' ,
12+ 'Move Schemes' : 'schemes' ,
13+ 'Simulations' : 'pathsimulators' ,
14+ 'Tags' : 'tags' ,
15+ 'Steps' : 'steps' ,
16+ 'Move Changes' : 'movechanges' ,
17+ 'SampleSets' : 'samplesets' ,
18+ 'Trajectories' : 'trajectories' ,
19+ 'Snapshots' : 'snapshots'
20+ }
21+
722@click .command (
823 'contents' ,
924 short_help = "list named objects from an OPS .nc file" ,
@@ -26,13 +41,22 @@ def contents(input_file, table):
2641 try :
2742 store = getattr (storage , table_attr )
2843 except AttributeError :
29- print ( "This needs to raise a good error; bad table name " )
44+ raise click . UsageError ( "Unknown table: '" + table_attr + "' " )
3045 else :
31- if table_attr in UNNAMED_SECTIONS :
32- print (get_unnamed_section_string (table_attr , store ))
33- else :
34- print (get_section_string_nameable (table_attr , store ,
35- _get_named_namedobj ))
46+ print (get_section_string (table_attr , store ))
47+
48+
49+ def get_section_string (label , store ):
50+ attr = NAME_TO_ATTR .get (label , label .lower ())
51+ if attr in UNNAMED_SECTIONS :
52+ string = get_unnamed_section_string (label , store )
53+ elif attr in ['tag' , 'tags' ]:
54+ string = get_section_string_nameable (label , store , _get_named_tags )
55+ else :
56+ string = get_section_string_nameable (label , store ,
57+ _get_named_namedobj )
58+ return string
59+
3660
3761def report_all_tables (storage ):
3862 store_section_mapping = {
0 commit comments