Skip to content

Commit e71a2e3

Browse files
committed
Fix station and instrument click option to parse geometry to float
- Fix country_id click option to be clear and precise
1 parent da8949b commit e71a2e3

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

woudc_data_registry/epicentre/contributor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def show(ctx, identifier, verbosity):
101101
@cli_options.OPTION_VERBOSITY
102102
@click.option('-n', '--name', 'name', required=True, help='name')
103103
@click.option('-a', '--acronym', 'acronym', required=True, help='acronym')
104-
@click.option('-c', '--country', 'country_id', required=True,
104+
@click.option('-c', '--country-id', 'country_id', required=True,
105105
help='country ID, ex: "CAN"')
106106
@click.option('-p', '--project', 'project', required=True, help='project')
107107
@click.option('-w', '--wmo-region', 'wmo_region', required=True,
@@ -146,7 +146,7 @@ def add(ctx, name, acronym, country_id, project, wmo_region,
146146
help='acronym')
147147
@click.option('-n', '--name', 'name', help='name')
148148
@click.option('-a', '--acronym', 'acronym', help='acronym')
149-
@click.option('-c', '--country', 'country', help='country')
149+
@click.option('-c', '--country-id', 'country_id', help='country ID, ex: "CAN"')
150150
@click.option('-p', '--project', 'project', help='project')
151151
@click.option('-w', '--wmo-region', 'wmo_region', help='WMO region')
152152
@click.option('-u', '--url', 'url', help='URL')
@@ -155,7 +155,7 @@ def add(ctx, name, acronym, country_id, project, wmo_region,
155155
@click.option('-sd', '--start-date', 'start_date', help='YYYY-MM-DD')
156156
@click.option('-ed', '--end-date', 'end_date', help='YYYY-MM-DD')
157157
@click.option('-g', '--geometry', 'geometry', help='latitude,longitude')
158-
def update(ctx, identifier, name, acronym, country, project,
158+
def update(ctx, identifier, name, acronym, country_id, project,
159159
wmo_region, url, email, ftp_username, start_date, end_date,
160160
geometry, verbosity):
161161
"""Update contributor information"""
@@ -168,8 +168,8 @@ def update(ctx, identifier, name, acronym, country, project,
168168
contributor_['name'] = name
169169
if acronym:
170170
contributor_['acronym'] = acronym
171-
if country:
172-
contributor_['country_id'] = country
171+
if country_id:
172+
contributor_['country_id'] = country_id
173173
if project:
174174
contributor_['project_id'] = project
175175
if wmo_region:

woudc_data_registry/epicentre/instrument.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ def update(ctx, identifier, station, dataset,
227227
if len(geom_tokens) == 2:
228228
geom_tokens.append(None)
229229

230-
instrument_['x'] = geom_tokens[1]
231-
instrument_['y'] = geom_tokens[0]
232-
instrument_['z'] = geom_tokens[2]
230+
instrument_['x'] = float(geom_tokens[1])
231+
instrument_['y'] = float(geom_tokens[0])
232+
instrument_['z'] = float(geom_tokens[2])
233233

234234
if len(instrument_.keys()) == 0:
235235
click.echo('No updates specified')

woudc_data_registry/epicentre/station.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ def show(ctx, identifier, verbosity):
125125
help='station type')
126126
@click.option('-n', '--name', 'name', required=True, help='name')
127127
@click.option('-gi', '--gaw-id', 'gaw_id', required=True, help='GAW ID')
128-
@click.option('-c', '--country', 'country', required=True, help='country')
128+
@click.option('-c', '--country-id', 'country_id', required=True,
129+
help='country ID, ex: "CAN"')
129130
@click.option('-w', '--wmo-region', 'wmo_region', required=True,
130131
help='WMO region')
131132
@click.option('-sd', '--start-date', 'start_date', required=True,
@@ -134,7 +135,7 @@ def show(ctx, identifier, verbosity):
134135
help='end date')
135136
@click.option('-g', '--geometry', 'geometry', required=True,
136137
help='latitude,longitude,elevation')
137-
def add(ctx, identifier, name, type_, gaw_id, country,
138+
def add(ctx, identifier, name, type_, gaw_id, country_id,
138139
wmo_region, start_date, end_date, geometry, verbosity):
139140
"""Add a station"""
140141

@@ -145,13 +146,13 @@ def add(ctx, identifier, name, type_, gaw_id, country,
145146
'station_name': name,
146147
'station_type': type_,
147148
'gaw_id': gaw_id,
148-
'country_id': country,
149+
'country_id': country_id,
149150
'wmo_region_id': wmo_region,
150151
'start_date': start_date,
151152
'end_date': end_date,
152-
'x': geom_tokens[1],
153-
'y': geom_tokens[0],
154-
'z': geom_tokens[2]
153+
'x': float(geom_tokens[1].strip()),
154+
'y': float(geom_tokens[0].strip()),
155+
'z': float(geom_tokens[2].strip())
155156
}
156157

157158
add_metadata(Station, station_, save_to_registry, save_to_index)
@@ -166,13 +167,13 @@ def add(ctx, identifier, name, type_, gaw_id, country,
166167
@click.option('-t', '--type', 'type_', help='station type')
167168
@click.option('-n', '--name', 'name', help='name')
168169
@click.option('-gi', '--gaw-id', 'gaw_id', help='GAW ID')
169-
@click.option('-c', '--country', 'country', help='country')
170+
@click.option('-c', '--country-id', 'country_id', help='country ID, ex: "CAN"')
170171
@click.option('-w', '--wmo-region', 'wmo_region', help='WMO region')
171172
@click.option('-sd', '--start-date', 'start_date', help='start date')
172173
@click.option('-ed', '--end-date', 'end_date', help='end date')
173174
@click.option('-g', '--geometry', 'geometry',
174175
help='latitude,longitude,elevation')
175-
def update(ctx, identifier, name, type_, gaw_id, country,
176+
def update(ctx, identifier, name, type_, gaw_id, country_id,
176177
wmo_region, start_date, end_date, geometry, verbosity):
177178
"""Update station information"""
178179

@@ -187,8 +188,8 @@ def update(ctx, identifier, name, type_, gaw_id, country,
187188
station_['station_type'] = type_
188189
if gaw_id:
189190
station_['gaw_id'] = gaw_id
190-
if country:
191-
station_['country_id'] = country
191+
if country_id:
192+
station_['country_id'] = country_id
192193
if wmo_region:
193194
station_['wmo_region_id'] = wmo_region
194195
if start_date:

0 commit comments

Comments
 (0)