def setUp(self): self.tmp_dir = tempfile.mkdtemp() data_format = get_data_format('application/json') self.complex_in = ComplexInput(identifier="complexinput", title='MyComplex', abstract='My complex input', workdir=self.tmp_dir, supported_formats=[data_format]) self.complex_in.data = "Hallo world!"
def setUp(self): self.tmp_dir = tempfile.mkdtemp() data_format = get_data_format('application/x-ogc-dods') self.complex_in = ComplexInput(identifier="complexinput", title='MyComplex', abstract='My complex input', keywords=['kw1', 'kw2'], workdir=self.tmp_dir, data_format=data_format, supported_formats=[data_format, get_data_format('application/x-netcdf')]) self.complex_in.href = "http://test.opendap.org:80/opendap/netcdf/examples/sresa1b_ncar_ccsm3_0_run1_200001.nc"
def json(self, value): """init this request from json back again :param value: the json (not string) representation """ self.operation = value['operation'] self.version = value['version'] self.language = value['language'] self.identifiers = value['identifiers'] self.store_execute = value['store_execute'] self.status = value['status'] self.lineage = value['lineage'] self.outputs = value['outputs'] self.raw = value['raw'] self.inputs = {} for identifier in value['inputs']: inpt = None inpt_defs = value['inputs'][identifier] for inpt_def in inpt_defs: if inpt_def['type'] == 'complex': inpt = ComplexInput( identifier=inpt_def['identifier'], title=inpt_def.get('title'), abstract=inpt_def.get('abstract'), workdir=inpt_def.get('workdir'), data_format=Format( schema=inpt_def['data_format'].get('schema'), extension=inpt_def['data_format'].get('extension'), mime_type=inpt_def['data_format']['mime_type'], encoding=inpt_def['data_format'].get('encoding') ), supported_formats=[ Format( schema=infrmt.get('schema'), extension=infrmt.get('extension'), mime_type=infrmt['mime_type'], encoding=infrmt.get('encoding') ) for infrmt in inpt_def['supported_formats'] ], mode=MODE.NONE ) inpt.file = inpt_def['file'] elif inpt_def['type'] == 'literal': allowed_values = [] for allowed_value in inpt_def['allowed_values']: if allowed_value['type'] == 'anyvalue': allowed_values.append(AnyValue()) elif allowed_value['type'] == 'novalue': allowed_values.append(NoValue()) elif allowed_value['type'] == 'valuesreference': allowed_values.append(ValuesReference()) elif allowed_value['type'] == 'allowedvalue': allowed_values.append(AllowedValue( allowed_type=allowed_value['allowed_type'], value=allowed_value['value'], minval=allowed_value['minval'], maxval=allowed_value['maxval'], spacing=allowed_value['spacing'], range_closure=allowed_value['range_closure'] )) inpt = LiteralInput( identifier=inpt_def['identifier'], title=inpt_def.get('title'), abstract=inpt_def.get('abstract'), data_type=inpt_def.get('data_type'), workdir=inpt_def.get('workdir'), allowed_values=AnyValue, uoms=inpt_def.get('uoms'), mode=inpt_def.get('mode') ) inpt.uom = inpt_def.get('uom') inpt.data = inpt_def.get('data') elif inpt_def['type'] == 'bbox': inpt = BBoxInput( identifier=inpt_def['identifier'], title=inpt_def['title'], abstract=inpt_def['abstract'], crss=inpt_def['crs'], dimensions=inpt_def['dimensions'], workdir=inpt_def['workdir'], mode=inpt_def['mode'] ) inpt.ll = inpt_def['bbox'][0] inpt.ur = inpt_def['bbox'][1] if identifier in self.inputs: self.inputs[identifier].append(inpt) else: self.inputs[identifier] = [inpt]
def json(self, value): """init this request from json back again :param value: the json (not string) representation """ self.operation = value['operation'] self.version = value['version'] self.language = value['language'] self.identifier = value['identifier'] self.identifiers = value['identifiers'] self.store_execute = value['store_execute'] self.status = value['status'] self.lineage = value['lineage'] self.outputs = value['outputs'] self.raw = value['raw'] self.inputs = {} for identifier in value['inputs']: inpt = None inpt_defs = value['inputs'][identifier] for inpt_def in inpt_defs: if inpt_def['type'] == 'complex': inpt = ComplexInput( identifier=inpt_def['identifier'], title=inpt_def.get('title'), abstract=inpt_def.get('abstract'), workdir=inpt_def.get('workdir'), data_format=Format( schema=inpt_def['data_format'].get('schema'), extension=inpt_def['data_format'].get('extension'), mime_type=inpt_def['data_format']['mime_type'], encoding=inpt_def['data_format'].get('encoding')), supported_formats=[ Format(schema=infrmt.get('schema'), extension=infrmt.get('extension'), mime_type=infrmt['mime_type'], encoding=infrmt.get('encoding')) for infrmt in inpt_def['supported_formats'] ], mode=MODE.NONE) inpt.file = inpt_def['file'] elif inpt_def['type'] == 'literal': allowed_values = [] for allowed_value in inpt_def['allowed_values']: if allowed_value['type'] == 'anyvalue': allowed_values.append(AnyValue()) elif allowed_value['type'] == 'novalue': allowed_values.append(NoValue()) elif allowed_value['type'] == 'valuesreference': allowed_values.append(ValuesReference()) elif allowed_value['type'] == 'allowedvalue': allowed_values.append( AllowedValue( allowed_type=allowed_value['allowed_type'], value=allowed_value['value'], minval=allowed_value['minval'], maxval=allowed_value['maxval'], spacing=allowed_value['spacing'], range_closure=allowed_value[ 'range_closure'])) inpt = LiteralInput(identifier=inpt_def['identifier'], title=inpt_def.get('title'), abstract=inpt_def.get('abstract'), data_type=inpt_def.get('data_type'), workdir=inpt_def.get('workdir'), allowed_values=AnyValue, uoms=inpt_def.get('uoms'), mode=inpt_def.get('mode')) inpt.uom = inpt_def.get('uom') inpt.data = inpt_def.get('data') elif inpt_def['type'] == 'bbox': inpt = BBoxInput(identifier=inpt_def['identifier'], title=inpt_def['title'], abstract=inpt_def['abstract'], crss=inpt_def['crs'], dimensions=inpt_def['dimensions'], workdir=inpt_def['workdir'], mode=inpt_def['mode']) inpt.ll = inpt_def['bbox'][0] inpt.ur = inpt_def['bbox'][1] if identifier in self.inputs: self.inputs[identifier].append(inpt) else: self.inputs[identifier] = [inpt]
def setUp(self): tmp_dir = tempfile.mkdtemp() data_format = get_data_format('application/json') self.complex_in = ComplexInput(identifier="complexinput", workdir=tmp_dir, supported_formats=[data_format])