Skip to content

Commit 156e1a3

Browse files
committed
Enable running on command line
1 parent a939486 commit 156e1a3

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

dms_datastore/dropbox_data.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from dms_datastore.read_ts import read_ts, infer_freq_robust
66
from dms_datastore.write_ts import write_ts_csv
77
from dms_datastore.dstore_config import station_dbase
8+
import argparse
89

910
# Global variable to store cached data
1011
_cached_spec = None
@@ -167,6 +168,14 @@ def dropbox_data(spec_fname):
167168
spec = get_spec(spec_fname)
168169
get_data(spec)
169170

170-
171-
if __name__ == "__name__" or True:
172-
dropbox_data("dropbox_spec.yaml")
171+
def create_arg_parser():
172+
parser = argparse.ArgumentParser("Reads unformatted data files and writes to formatted csv files according to dropbox specification.")
173+
parser.add_argument('--input',default=False,help=".yaml file with dropbox specification")
174+
return parser
175+
176+
def main():
177+
parser = create_arg_parser()
178+
args = parser.parse_args()
179+
if not args.input:
180+
raise ValueError("input yaml file required")
181+
dropbox_data(args.input)

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@
8181
"usgs_multi=dms_datastore.usgs_multi:main",
8282
"delete_from_filelist=dms_datastore.delete_from_filelist:main",
8383
"data_cache=dms_datastore.caching:main",
84-
"merge_files=dms_datastore.merge_files:main"
84+
"merge_files=dms_datastore.merge_files:main",
85+
"dropbox_data=dms_datastore.dropbox_data:main"
8586
]
8687
},
8788
)

0 commit comments

Comments
 (0)