def update(ctx, identifier, name, contributor, gaw_id, country, wmo_region, start_date, end_date, geometry): """Update station information""" station_ = {'last_validated_datetime': datetime.utcnow()} if name: station_['name'] = name if contributor: station_['contributor'] = contributor if gaw_id: station_['gaw_id'] = gaw_id if country: station_['country'] = country if wmo_region: station_['wmo_region'] = wmo_region if start_date: station_['start_date'] = start_date if end_date: station_['end_date'] = end_date if geometry: geom_tokens = geometry.split(',') station_['x'] = geom_tokens[0] station_['y'] = geom_tokens[1] station_['z'] = geom_tokens[2] if len(station_.keys()) == 1: click.echo('No updates specified') return update_metadata(Station, identifier, station_) click.echo('Station {} updated'.format(identifier))
def update(ctx, identifier, name, country, wmo_region, url, email, ftp_username, geometry): """Update contributor information""" contributor_ = { 'last_validated_datetime': datetime.utcnow() } if name: contributor_['name'] = name if wmo_region: contributor_['wmo_region'] = wmo_region if url: contributor_['url'] = url if email: contributor_['email'] = email if ftp_username: contributor_['ftp_username'] = ftp_username if geometry: geom_tokens = geometry.split(',') contributor_['x'] = geom_tokens[0] contributor_['y'] = geom_tokens[1] if len(contributor_.keys()) == 1: click.echo('No updates specified') return update_metadata(Contributor, identifier, contributor_) click.echo('Contributor {} updated'.format(identifier))
def update(ctx, identifier, name, acronym, country, project, wmo_region, url, email, ftp_username, geometry): """Update contributor information""" contributor_ = {'last_validated_datetime': datetime.utcnow()} if name: contributor_['name'] = name if acronym: contributor_['acronym'] = acronym if country: contributor_['country_id'] = country if project: contributor_['project_id'] = project if wmo_region: contributor_['wmo_region_id'] = wmo_region if url: contributor_['url'] = url if email: contributor_['email'] = email if ftp_username: contributor_['ftp_username'] = ftp_username if geometry: geom_tokens = geometry.split(',') contributor_['x'] = geom_tokens[1] contributor_['y'] = geom_tokens[0] if len(contributor_.keys()) == 1: click.echo('No updates specified') return update_metadata(Contributor, identifier, contributor_, save_to_registry, save_to_index) click.echo('Contributor {} updated'.format(identifier))
def update(ctx, identifier, path): """Update news notification""" with open(path) as news_file: notification = yaml.safe_load(news_file) if len(notification.keys()) == 1: click.echo('No updates specified') return update_metadata(Notification, identifier, notification, save_to_registry, save_to_index) click.echo('Notification {} updated'.format(identifier))
def update(ctx, identifier, station, dataset, contributor, name, model, serial, geometry): """Update instrument information""" instrument_ = {} if station: instrument_['station_id'] = station if dataset: instrument_['dataset_id'] = dataset if station or contributor: if station and (not contributor): inst = get_metadata(Instrument, identifier) cbtr = inst[0].deployment.contributor_id instrument_['deployment_id'] = ':'.join([station, cbtr]) elif contributor and (not station): inst = get_metadata(Instrument, identifier) stn = inst[0].station_id instrument_['deployment_id'] = ':'.join([stn, contributor]) elif contributor and station: instrument_['deployment_id'] = ':'.join([station, contributor]) if name: instrument_['name'] = name if model: instrument_['model'] = model if serial: instrument_['serial'] = serial if geometry: geom_tokens = geometry.split(',') if len(geom_tokens) == 2: geom_tokens.append(None) instrument_['x'] = geom_tokens[1] instrument_['y'] = geom_tokens[0] instrument_['z'] = geom_tokens[2] if len(instrument_.keys()) == 0: click.echo('No updates specified') return update_metadata(Instrument, identifier, instrument_, save_to_registry, save_to_index) click.echo('Instrument {} updated'.format(identifier))
def update(ctx, identifier, station, contributor, start_date, end_date): """Update deployment information""" deployment_ = {} if station: deployment_['station_id'] = station if contributor: deployment_['contributor_id'] = contributor if start_date: deployment_['start_date'] = start_date.date() if end_date: deployment_['end_date'] = end_date.date() if len(deployment_.keys()) == 0: click.echo('No updates specified') return update_metadata(Deployment, identifier, deployment_, save_to_registry, save_to_index) click.echo('Deployment {} updated'.format(identifier))