def populate_figure(fig_json): f = Figure({}) try: if fig_json['graphics_title'].startswith('ES'): title_fields = fig_json['graphics_title'].split('. ') title = ' '.join(title_fields[1:]) f.ordinal = re.search('\d+', title_fields[0]).group(0) else: figure_num, title = parse_title(fig_json['graphics_title']) if figure_num and figure_num.startswith('TSD'): f.ordinal = figure_num.split('.')[1] else: f.figure_num = figure_num if figure_num else None f.title = title f.identifier = fig_json['figure_id'] if fig_json[ 'figure_id'] else re.sub('\W', '_', f.title).lower() f.create_dt = fig_json['graphics_create_date'].strip() if any(fig_json['period_record']): f.time_start, f.time_end = [ d.strip() for d in fig_json['period_record'] ] f.lat_min, f.lat_max, f.lon_min, f.lon_max = fig_json['spatial_extent'] except Exception, e: warning('Figure exception: ', e) traceback.print_exc()
def populate_figure(fig_json): f = Figure({}) try: f.figure_num, f.title = parse_title(fig_json['graphics_title']) f.identifier = fig_json['figure_id'] if fig_json['figure_id'] else re.sub('\W', '_', f.title).lower() f.create_dt = fig_json['graphics_create_date'] f.time_start, f.time_end = fig_json['period_record'] f.lat_min, f.lat_max, f.lon_min, f.lon_max = fig_json['spatial_extent'] f.remote_path = fig_json['filepath'] except Exception, e: print 'Figure exception: ', e
def populate_figure(fig_json): f = Figure({}) try: f.figure_num, f.title = parse_title(fig_json['graphics_title']) f.identifier = fig_json['figure_id'] if fig_json[ 'figure_id'] else re.sub('\W', '_', f.title).lower() f.create_dt = fig_json['graphics_create_date'] f.time_start, f.time_end = fig_json['period_record'] f.lat_min, f.lat_max, f.lon_min, f.lon_max = fig_json['spatial_extent'] f.remote_path = fig_json['filepath'] except Exception, e: print 'Figure exception: ', e
def populate_figure(fig_json): f = Figure({}) try: figure_num, title = parse_title(fig_json['graphics_title']) f.ordinal = figure_num if figure_num else None f.title = title f.identifier = fig_json['figure_id'] if fig_json[ 'figure_id'] else re.sub('\W', '_', f.title).lower() f.create_dt = fig_json['graphics_create_date'].strip() if any(fig_json['period_record']): f.time_start, f.time_end = [ d.strip() for d in fig_json['period_record'] ] f.lat_min, f.lat_max, f.lon_min, f.lon_max = fig_json['spatial_extent'] except Exception, e: warning('Figure exception: ', e) traceback.print_exc()