This repository has been archived by the owner on Oct 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathmanage.py
executable file
·54 lines (41 loc) · 1.77 KB
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3.6
"""
Entrypoint for Flask development server.
"""
import click
from flask.cli import FlaskGroup
from waterdata import app
cli = FlaskGroup(create_app=lambda script_info: app)
@cli.command()
@click.option('--datadir', type=click.Path(dir_okay=True, file_okay=False),
default=app.config.get('DATA_DIR'),
help='Output directory for generation JSON file.')
@click.option('--all', 'gen_all', is_flag=True, default=False,
help='Generate all lookup files.')
@click.option('--nwis', is_flag=True, default=False,
help='Generate the NWIS code lookup file.')
@click.option('--regions', is_flag=True, default=False,
help='Generate the region lookup file.')
@click.option('--huc', is_flag=True, default=False,
help='Generate the HUC lookup file.')
def generate_lookups(datadir, **lookups):
"""
Creates lookup file(s) from NWIS web services in the specified directory.
"""
if not any(lookups.values()):
click.echo('No lookups specified.')
return
if lookups['nwis'] or lookups['gen_all']:
click.echo('Generating NWIS code lookup file...')
from waterdata.commands.lookup_generation import generate_lookup_file
generate_lookup_file(datadir)
if lookups['regions'] or lookups['gen_all']:
click.echo('Generating region lookup file...')
from waterdata.commands.lookup_generation import generate_country_state_county_file
generate_country_state_county_file(datadir)
if lookups['huc'] or lookups['gen_all']:
click.echo('Generating HUC lookup file...')
from waterdata.commands.lookup_generation.huc_lookups import generate_hucs_file
generate_hucs_file(datadir)
if __name__ == '__main__':
cli()