22# TODO: Move all the Python into new file rimport.py for simpler testing. Keep rimport as a
33# convenience wrapper.
44"""
5- A drop-in CLI replacement for the legacy `rimport` csh tool.
6-
7- This script preserves the original command-line interface:
8-
9- SYNOPSIS
10- rimport [-file filename] [-list filelist] [-inputdata inputdata_dir] [-help]
11-
12- OPTIONS
13- -file filename
14- provide a single filename relative to the top inputdata directory
15- -list filelist
16- provide a file that contains a list of filenames to import. all filenames
17- in the list are relative to the top inputdata area.
18- -inputdata inputdata_dir
19- change the default local top level inputdata directory
20- -help
21- get help about this tool
22-
23- Customize the `do_new_action(path)` function to implement the new behavior.
24- By default, it prints which files would be processed.
5+ Copy files from CESM inputdata directory to a publishing directory.
6+
7+ Do `rimport --help` for more information.
258"""
269from __future__ import annotations
2710
@@ -34,43 +17,27 @@ from pathlib import Path
3417from typing import Iterable , List
3518
3619
37- class PlainHelpFormatter (argparse .RawTextHelpFormatter ):
38- pass
39-
40-
4120def build_parser () -> argparse .ArgumentParser :
42- synopsis = (
43- "rimport [-file filename] [-list filelist] [-inputdata inputdata_dir] [-help]"
44- )
45-
46- description = (
47- "SYNOPSIS\n "
48- f" { synopsis } \n \n "
49- "OPTIONS\n "
50- " -file filename\n "
51- " provide a single filename relative to the top inputdata directory\n "
52- " -list filelist\n "
53- " provide a file that contains a list of filenames to import. all filenames\n "
54- " in the list are relative to the top inputdata area.\n "
55- " -inputdata inputdata_dir\n "
56- " change the default local top level inputdata directory\n "
57- " -help\n "
58- " get help about this tool\n "
59- )
60-
6121 parser = argparse .ArgumentParser (
62- prog = "rimport" ,
63- description = description ,
64- formatter_class = PlainHelpFormatter ,
65- add_help = False , # preserve original -help only
66- usage = synopsis ,
22+ description = "Copy files from CESM inputdata directory to a publishing directory."
6723 )
6824
6925 # Mutually exclusive: -file or -list (one required)
7026 group = parser .add_mutually_exclusive_group (required = True )
71- group .add_argument ("-file" , dest = "file" , metavar = "filename" , help = argparse .SUPPRESS )
7227 group .add_argument (
73- "-list" , dest = "filelist" , metavar = "filelist" , help = argparse .SUPPRESS
28+ "-file" ,
29+ dest = "file" ,
30+ metavar = "filename" ,
31+ help = "Provide a single filename relative to the top inputdata directory" ,
32+ )
33+ group .add_argument (
34+ "-list" ,
35+ dest = "filelist" ,
36+ metavar = "filelist" ,
37+ help = (
38+ "Provide a file that contains a list of filenames to import. All filenames in the list"
39+ "are relative to the top inputdata area."
40+ ),
7441 )
7542
7643 parser .add_argument (
@@ -80,12 +47,9 @@ def build_parser() -> argparse.ArgumentParser:
8047 default = os .path .join (
8148 "/glade" , "campaign" , "cesm" , "cesmdata" , "cseg" , "inputdata"
8249 ),
83- help = argparse . SUPPRESS ,
50+ help = "Change the default local top level inputdata directory." ,
8451 )
8552
86- # Provide -help to mirror legacy behavior
87- parser .add_argument ("-help" , action = "help" , help = argparse .SUPPRESS )
88-
8953 return parser
9054
9155
0 commit comments