def __init__(self): self.variables = ['tas', 'pr', 'psl', 'ts'] self.frequency = 'mon' inputs = [ *model_experiment_ensemble(model='ACCESS1-0', experiment='historical', ensemble='r1i1p1', required_variables=self.variables, required_frequency=self.frequency), *year_ranges((1850, 2005)), ] outputs = [ ComplexOutput('tas_trend_ann_plot', 'Annual TAS trend', abstract='Annual trend in surface air temperature.', as_reference=True, supported_formats=[Format('image/png')]), ComplexOutput('sst_trend_ann_plot', 'Annual SST trend', abstract='Annual trend in sea surface temperature.', as_reference=True, supported_formats=[Format('image/png')]), ComplexOutput('psl_trend_ann_plot', 'Annual PSL trend', abstract='Annual trend in sea level pressure.', as_reference=True, supported_formats=[Format('image/png')]), ComplexOutput('pr_trend_ann_plot', 'Annual precipitation trend', abstract='Annual trend in precipitation.', as_reference=True, supported_formats=[Format('image/png')]), ComplexOutput( 'archive', 'Archive', abstract= 'The complete output of the ESMValTool processing as an zip archive.', as_reference=True, supported_formats=[Format('application/zip')]), *default_outputs(), ] super(CVDP, self).__init__( self._handler, identifier="cvdp", title="NCAR CVDPackage", version=runner.VERSION, abstract="Run the NCAR CVDPackage", metadata=[ Metadata('ESMValTool', 'http://www.esmvaltool.org/'), Metadata( 'Documentation', 'https://esmvaltool.readthedocs.io/en/version2_development/recipes/recipe_cvdp.html', role=util.WPS_ROLE_DOC), Metadata('Estimated Calculation Time', '2 Minutes'), ], inputs=inputs, outputs=outputs, status_supported=True, store_supported=True)
def __init__(self): self.status_percentage_steps = dict( common_status_percentages, **{ "load_rdata": 10, "save_rdata": 90, }, ) inputs = ptot_inputs outputs = [rda_output] super(ClimdexPtot, self).__init__( self._handler, identifier="climdex_ptot", title="Climdex Temperature Percentiles", abstract="Total daily precipitation exceeding threshold", metadata=[ Metadata("NetCDF processing"), Metadata("Climate Data Operations"), Metadata("PyWPS", "https://pywps.org/"), Metadata("Birdhouse", "http://bird-house.github.io/"), Metadata("PyWPS Demo", "https://pywps-demo.readthedocs.io/en/latest/"), ], inputs=inputs, outputs=outputs, store_supported=True, status_supported=True, )
def __init__(self): self.status_percentage_steps = dict( common_status_percentages, **{ "load_rdata": 10, "save_rdata": 90, }, ) inputs = spells_inputs outputs = [rda_output] super(ClimdexSpells, self).__init__( self._handler, identifier="climdex_spells", title="Climdex Spells", abstract="Cold (csdi) or warm (wsdi) spell duration index and maximum consecutive dry (cdd) or wet (cwd) days", metadata=[ Metadata("NetCDF processing"), Metadata("Climate Data Operations"), Metadata("PyWPS", "https://pywps.org/"), Metadata("Birdhouse", "http://bird-house.github.io/"), Metadata("PyWPS Demo", "https://pywps-demo.readthedocs.io/en/latest/"), ], inputs=inputs, outputs=outputs, store_supported=True, status_supported=True, )
def __init__(self): self.status_percentage_steps = dict( common_status_percentages, **{ "load_rdata": 10, "save_rdata": 90, }, ) inputs = rmm_inputs outputs = [rda_output] super(ClimdexRMM, self).__init__( self._handler, identifier="climdex_rmm", title="Climdex RMM", abstract= "The annual count of days where daily precipitation is more than [threshold] mm per day", metadata=[ Metadata("NetCDF processing"), Metadata("Climate Data Operations"), Metadata("PyWPS", "https://pywps.org/"), Metadata("Birdhouse", "http://bird-house.github.io/"), Metadata("PyWPS Demo", "https://pywps-demo.readthedocs.io/en/latest/"), ], inputs=inputs, outputs=outputs, store_supported=True, status_supported=True, )
def __init__(self): inputs = [ ComplexInput('text', 'Text document', abstract='URL pointing to a text document, for example "Alice in Wonderland":' ' http://www.gutenberg.org/cache/epub/19033/pg19033.txt', supported_formats=[Format('text/plain')]), ] outputs = [ ComplexOutput('output', 'Word counter result', as_reference=True, supported_formats=[Format('application/json')]), ] super(WordCounter, self).__init__( self._handler, identifier='wordcounter', title='Word Counter', abstract="Counts words in a given text.", version='1.0', metadata=[ Metadata('User Guide', 'http://emu.readthedocs.io/en/latest/'), Metadata('Free eBooks at Gutenberg', 'http://www.gutenberg.org/'), Metadata('Example: Alice in Wonderland', 'http://www.gutenberg.org/cache/epub/19033/pg19033.txt'), ], inputs=inputs, outputs=outputs, store_supported=True, status_supported=True)
def __init__(self): self.status_percentage_steps = { "start": 0, "process": 10, "build_output": 95, "complete": 100, } inputs = [ ComplexInput( "netcdf", "NetCDF Datasets", abstract="NetCDF files to process", min_occurs=1, max_occurs=MAX_OCCURS, supported_formats=[FORMATS.NETCDF, FORMATS.DODS], ), log_level, ] outputs = [meta4_output] super(SplitMergedClimos, self).__init__( self._handler, identifier="split_merged_climos", title="Split Merged Climos", abstract="Split climo means files into one file per time interval", metadata=[ Metadata("NetCDF processing"), Metadata("Climate Data Operations"), ], inputs=inputs, outputs=outputs, store_supported=True, status_supported=True, )
def __init__(self): inputs = [] outputs = [ ComplexOutput( 'nc', 'NetCDF', as_reference=True, supported_formats=[FORMATS.NETCDF], ), ComplexOutput( 'preview', 'Preview', abstract='Preview of subsetted Dataset.', as_reference=True, supported_formats=[Format('image/png')], ), ] super(PelicanSubset, self).__init__( self._handler, identifier='pelican_subset', title='xarray.subset', abstract="subset netcdf files", version='2.0.0', metadata=[ Metadata('ESGF Compute API', 'https://github.com/ESGF/esgf-compute-api'), Metadata('ESGF Compute WPS', 'https://github.com/ESGF/esgf-compute-wps'), ], inputs=inputs, outputs=outputs, store_supported=True, status_supported=True)
def __init__(self): self.status_percentage_steps = dict( common_status_percentages, **{ "load_rdata": 10, "save_rdata": 90, }, ) inputs = gsl_inputs outputs = [rda_output] super(ClimdexGSL, self).__init__( self._handler, identifier="climdex_gsl", title="Climdex Growing Seasonal Length", abstract="Computes the growing season length (GSL)", metadata=[ Metadata("NetCDF processing"), Metadata("Climate Data Operations"), Metadata("PyWPS", "https://pywps.org/"), Metadata("Birdhouse", "http://bird-house.github.io/"), Metadata("PyWPS Demo", "https://pywps-demo.readthedocs.io/en/latest/"), ], inputs=inputs, outputs=outputs, store_supported=True, status_supported=True, )
def __init__(self): inputs = [ ComplexInput('filesIn', 'Input NetCDF Files URL', abstract='Input NetCDF Files URL.', supported_formats=[Format('JSON')], mode=MODE.STRICT) ] outputs = [ LiteralOutput('output', 'Output response', abstract='Output response.', data_type='string') ] super(Repackage, self).__init__( self._handler, identifier='repackage', title='Repackage', abstract='Repackage a list of NetCDF files.' 'For now returns an ncdump of the merge of the input files.', metadata=[ Metadata('PyWPS', 'https://pywps.org/'), Metadata('Birdhouse', 'http://bird-house.github.io/') ], version='0.1', inputs=inputs, outputs=outputs, store_supported=True, status_supported=True)
def __init__(self): inputs = [ LiteralInput( 'message', 'Error Message', data_type='string', abstract='Enter an error message that will be returned.', default="This process failed intentionally.", min_occurs=1, ), LiteralInput( 'nice', 'Be nice and show a friendly error message. Default: true', data_type='boolean', default=True, ), ] super(ShowError, self).__init__( self._handler, identifier='show_error', title='Show a WPS Error', abstract= 'This process will fail intentionally with a friendly WPS error message.', metadata=[ Metadata('PyWPS', 'https://pywps.org/'), Metadata('Birdhouse', 'http://bird-house.github.io/'), Metadata('User Guide', 'http://emu.readthedocs.io/en/latest/') ], version='1.0', inputs=inputs, # outputs=outputs, store_supported=True, status_supported=True)
def __init__(self): self.status_percentage_steps = dict( common_status_percentages, **{ "load_rdata": 10, "save_rdata": 90, }, ) inputs = rxnday_inputs outputs = [rda_output] super(ClimdexRxnday, self).__init__( self._handler, identifier="climdex_rxnday", title="Climdex Monthly Maximum n (1 or 5) day Precipitation", abstract="Computes the mean daily diurnal temperature range.", metadata=[ Metadata("NetCDF processing"), Metadata("Climate Data Operations"), Metadata("PyWPS", "https://pywps.org/"), Metadata("Birdhouse", "http://bird-house.github.io/"), Metadata("PyWPS Demo", "https://pywps-demo.readthedocs.io/en/latest/"), ], inputs=inputs, outputs=outputs, store_supported=True, status_supported=True, )
def __init__(self): inputs = [ ComplexInput('bc_table', 'BC table', abstract='BCtable', min_occurs=1, max_occurs=1, supported_formats=[ Format('text/plain'), ]), ] outputs = [metalink, outlog, errlog] super(BCExtractor, self).__init__( self._handler, identifier='bcextractor', title='BC Extractor', abstract='Boundary Condition extractor for WRF model', keywords=['WRF', 'boundary'], metadata=[ Metadata('PyWPS', 'https://pywps.org/'), Metadata('Birdhouse', 'http://bird-house.github.io/'), Metadata('PyWPS Demo', 'https://pywps-demo.readthedocs.io/en/latest/'), Metadata('Emu: PyWPS examples', 'https://emu.readthedocs.io/en/latest/'), ], version='1.5', inputs=inputs, outputs=outputs, store_supported=True, status_supported=True)
def __init__(self): self.status_percentage_steps = dict( common_status_percentages, **{ "load_rdata": 10, "save_rdata": 90, }, ) inputs = mmdmt_inputs outputs = [rda_output] super(ClimdexMMDMT, self).__init__( self._handler, identifier="climdex_mmdmt", title="Climdex MMDMT", abstract=""" climdex_mmdmt includes the functions: - climdex.txx: Monthly (or annual) Maximum of Daily Maximum Temperature - climdex.tnx: Monthly (or annual) Maximum of Daily Minimum Temperature - climdex.txn: Monthly (or annual) Minimum of Daily Maximum Temperature - climdex.tnn: Monthly (or annual) Minimum of Daily Minimum Temperature """, metadata=[ Metadata("NetCDF processing"), Metadata("Climate Data Operations"), Metadata("PyWPS", "https://pywps.org/"), Metadata("Birdhouse", "http://bird-house.github.io/"), Metadata("PyWPS Demo", "https://pywps-demo.readthedocs.io/en/latest/"), ], inputs=inputs, outputs=outputs, store_supported=True, status_supported=True, )
def __init__(self): inputs = [ LiteralInput( 'taxon_name', 'Taxonomic name of tree species', abstract= 'Taxonomic name of tree species (e. g. Fagus sylvatica)', data_type='string', min_occurs=1, max_occurs=1, default='Fagus sylvatica'), ] # self.BBox = self.addBBoxInput( # # identifier="BBox", # # title="Bounding Box", # # abstract="coordinates to define the region for occurence data fetch", # # minOccurs=1, # # maxOccurs=1, # # crss=['EPSG:4326'] outputs = [ ComplexOutput( 'output_map', 'Graphic of species occurences', abstract="PNG graphic file showing the presence of tree species \ according to GBIF data fetch", as_reference=True, supported_formats=[Format('image/png')]), ComplexOutput( 'output_csv', 'Tree species table', abstract="Extracted CSV file containing the tree species table", as_reference=True, supported_formats=[Format('text/csv')]), ComplexOutput('output_log', 'Logging information', abstract="Collected logs during process run.", as_reference=True, supported_formats=[Format('text/plain')]) ] super(GBIFfetchProcess, self).__init__( self._handler, identifier="sdm_gbiffetch", title="Species distribution Model (GBIF data fetch only)", version="0.2", abstract="Species occurence search in Global Biodiversity \ Infrastructure Facillity (GBIF)", metadata=[ # Metadata('LSCE', 'http://www.lsce.ipsl.fr/en/index.php'), Metadata('Doc', 'http://flyingpigeon.readthedocs.io/en/latest/'), Metadata('GBIF', 'http://gbif.org/') ], inputs=inputs, outputs=outputs, status_supported=True, store_supported=True, )
def __init__(self): inputs = [ LiteralInput('delay', 'Delay between every update', data_type='float') ] outputs = [ LiteralOutput('sleep_output', 'Sleep Output', data_type='string') ] super(Sleep, self).__init__( self._handler, identifier='sleep', version='None', title='Sleep Process', abstract="The process will sleep for a given delay \ or 10 seconds if not a valid value", profile='', metadata=[Metadata('Sleep'), Metadata('Wait'), Metadata('Delay')], inputs=inputs, outputs=outputs, store_supported=True, status_supported=True)
def __init__(self): inputs = [ LiteralInput('delay', 'Delay between every update', default='1', data_type='float') ] outputs = [ LiteralOutput('output', 'Nap Output', data_type='string') ] super(Nap, self).__init__( self._handler, identifier='nap', version='1.0', title='Afternoon Nap (supports sync calls only)', abstract='This process will have a short nap for a given delay or 1 second if not a valid value.\ This procces only supports synchronous WPS requests ... \ so, make sure the nap does not take to long.', profile='', metadata=[ Metadata('Birdhouse', 'http://bird-house.github.io/'), Metadata('User Guide', 'http://emu.readthedocs.io/en/latest/')], inputs=inputs, outputs=outputs, store_supported=False, status_supported=False )
def __init__(self): inputs = [ LiteralInput('name', 'Your name', abstract='Please enter your name.', data_type='string')] outputs = [ LiteralOutput('output', 'Output response', abstract='A friendly Hello from us.', data_type='string')] super(SayHello, self).__init__( self._handler, identifier='hello', title='Say Hello', abstract='Just says a friendly Hello.' 'Returns a literal string output with Hello plus the inputed name.', metadata=[ Metadata('User Guide', 'https://emu.readthedocs.io/en/latest/processes.html'), # noqa Metadata('PyWPS Demo', 'https://pywps-demo.readthedocs.io/en/latest/'), ], version='1.5', inputs=inputs, outputs=outputs, store_supported=True, status_supported=True )
def test_get_input_title(self): """Test returning the proper input title""" # configure def donothing(*args, **kwargs): pass process = Process(donothing, "process", title="Process", inputs=[ LiteralInput("length", title="Length"), BoundingBoxInput("bbox", title="BBox", crss=[]), ComplexInput("vector", title="Vector") ], outputs=[], metadata=[ Metadata('process metadata 1', 'http://example.org/1'), Metadata('process metadata 2', 'http://example.org/2') ]) inputs = {input.identifier: input.title for input in process.inputs} self.assertEqual("Length", inputs['length']) self.assertEqual("BBox", inputs["bbox"]) self.assertEqual("Vector", inputs["vector"])
def __init__(self): inputs = [ LiteralInput('name', 'Your name', abstract='Please enter your name.', keywords=['name', 'firstname'], data_type='string'),] outputs = [ LiteralOutput('output', 'Output response', abstract='A friendly Hello from us.', keywords=['output', 'result', 'response'], data_type='string')] super(SayHello, self).__init__( self._handler, identifier='hello', title='Say Hello', abstract='Just says a friendly Hello.' 'Returns a literal string output with Hello plus the inputed name.', keywords=['hello', 'demo'], metadata=[ Metadata('PyWPS', 'https://pywps.org/'), Metadata('Birdhouse', 'http://bird-house.github.io/'), Metadata('PyWPS Demo', 'https://pywps-demo.readthedocs.io/en/latest/'), Metadata('Emu: PyWPS examples', 'https://emu.readthedocs.io/en/latest/'), ], version='1.5', inputs=inputs, outputs=outputs, store_supported=True, status_supported=True )
def __init__(self): inputs = [ LiteralInput('delay', 'Delay between every update', default='10', data_type='float') ] outputs = [ LiteralOutput('sleep_output', 'Sleep Output', data_type='string') ] super(Sleep, self).__init__( self._handler, identifier='sleep', version='1.0', title='Sleep Process', abstract='Testing a long running process, in the sleep.' 'This process will sleep for a given delay or 10 seconds if not a valid value.', profile='', metadata=[ Metadata('User Guide', 'https://emu.readthedocs.io/en/latest/processes.html'), # noqa Metadata('PyWPS Demo', 'https://pywps-demo.readthedocs.io/en/latest/'), ], inputs=inputs, outputs=outputs, store_supported=True, status_supported=True )
def __init__(self): # Input [in json format ] inputs = [ LiteralInput("layer_name", "name of layer in db", data_type="string"), LiteralInput("json_matrix", "matrix with priorities", data_type="string"), ] # Output [in json format] outputs = [ ComplexOutput( "output_json", "Ra2ce calculation of costs", supported_formats=[Format("application/json")], ) ] super(WpsRa2ceRatio, self).__init__( self._handler, identifier="ra2ce_calc_ratio", version="1.0", title="backend process for the RA2CE POC, calculates the ratio between Annual Repair costs and Societial Costs", abstract="It uses PostgreSQL to calculate the ratio\ using 2 columns of a table and answer via a JSON reply, wrapped in the xml/wps format with the wmslayer to show", profile="", metadata=[Metadata("WpsRa2ceRatio"), Metadata("Ra2CE/ratio")], inputs=inputs, outputs=outputs, store_supported=False, status_supported=False, )
def __init__(self): self.status_percentage_steps = dict( common_status_percentages, **{ "load_rdata": 10, "save_rdata": 90, }, ) inputs = sdii_inputs outputs = [rda_output] super(ClimdexSDII, self).__init__( self._handler, identifier="climdex_sdii", title="Climdex Simple Precipitation Intensity Index", abstract= "Defined as the sum of precipitation in wet days (days with preciptitation over 1mm) during the year divided by the number of wet days in the year.", metadata=[ Metadata("NetCDF processing"), Metadata("Climate Data Operations"), Metadata("PyWPS", "https://pywps.org/"), Metadata("Birdhouse", "http://bird-house.github.io/"), Metadata("PyWPS Demo", "https://pywps-demo.readthedocs.io/en/latest/"), ], inputs=inputs, outputs=outputs, store_supported=True, status_supported=True, )
def setUp(self): def pr1(): pass def pr2(): pass self.client = client_for( Service(processes=[ Process( pr1, "pr1", "Process 1", abstract="Process 1", keywords=["kw1a", "kw1b"], metadata=[Metadata("pr1 metadata")], ), Process( pr2, "pr2", "Process 2", keywords=["kw2a"], metadata=[Metadata("pr2 metadata")], ), ]))
def __init__(self): super(DoNothing, self).__init__(self.donothing, "process", title="Process", abstract="Process description", inputs=[ LiteralInput("length", title="Length"), BoundingBoxInput("bbox", title="BBox", crss=[]), ComplexInput("vector", title="Vector", supported_formats=[FORMATS.GML]) ], outputs=[], metadata=[ Metadata('process metadata 1', 'http://example.org/1'), Metadata('process metadata 2', 'http://example.org/2') ], translations={ "fr-CA": { "title": "Processus", "abstract": "Une description" } })
def __init__(self): inputs = [ LiteralInput('inputa', 'Input 1', data_type='float', abstract='Enter Input 1', default="2.0"), LiteralInput('inputb', 'Input 2', data_type='float', abstract='Enter Input 2', default="3.0"), LiteralInput('operator', 'Operator', data_type='string', abstract='Choose a binary Operator', default='add', allowed_values=['add', 'substract', 'divide', 'multipy'])] outputs = [ LiteralOutput('output', 'Binary operator result', data_type='float')] super(BinaryOperator, self).__init__( self._handler, identifier='binaryoperatorfornumbers', title='Binary Operator for Numbers', abstract='Performs operation on two numbers and returns the answer.\ This example process is taken from Climate4Impact.', metadata=[ Metadata('Birdhouse', 'http://bird-house.github.io/'), Metadata('User Guide', 'http://emu.readthedocs.io/en/latest/'), Metadata('Climate4Impact', 'https://dev.climate4impact.eu')], version='1.0', inputs=inputs, outputs=outputs, store_supported=True, status_supported=True )
def __init__(self): self.status_percentage_steps = dict( common_status_percentages, **{"load_rdata": 10}, ) inputs = avail_indices_inputs outputs = [ LiteralOutput( "avail_processes", "Available processes dictionary", abstract= "Available climdex indices (values) and the processes to use to compute them (keys)", data_type="string", ), ] super(GetIndices, self).__init__( self._handler, identifier="climdex_get_available_indices", title="Climdex Get Available Indices", abstract= "Returns the names of all the indices which may be computed or, if get_function_names is TRUE, the names of the functions corresponding to the indices.", metadata=[ Metadata("NetCDF processing"), Metadata("Climate Data Operations"), Metadata("PyWPS", "https://pywps.org/"), Metadata("Birdhouse", "http://bird-house.github.io/"), Metadata("PyWPS Demo", "https://pywps-demo.readthedocs.io/en/latest/"), ], inputs=inputs, outputs=outputs, store_supported=True, status_supported=True, )
def __init__(self): self.status_percentage_steps = dict( common_status_percentages, **{ "load_rdata": 10, "save_rdata": 90, }, ) inputs = temp_pctl_inputs outputs = [rda_output] super(ClimdexTempPctl, self).__init__( self._handler, identifier="climdex_temp_pctl", title="Climdex Temperature Percentiles", abstract= "Percent of Values Above/Below 10th/90th Percentile Daily Maximum/Minimum Temperature", metadata=[ Metadata("NetCDF processing"), Metadata("Climate Data Operations"), Metadata("PyWPS", "https://pywps.org/"), Metadata("Birdhouse", "http://bird-house.github.io/"), Metadata("PyWPS Demo", "https://pywps-demo.readthedocs.io/en/latest/"), ], inputs=inputs, outputs=outputs, store_supported=True, status_supported=True, )
def __init__(self): inputs = [ BoundingBoxInput('bbox', 'Bounding Box', abstract='Bounding Box Input.', crss=['epsg:4326', 'epsg:3035'], min_occurs=0) ] outputs = [ BoundingBoxOutput('bbox', 'Bounding Box', abstract='Bounding Box Output.', crss=['epsg:4326']) ] super(Box, self).__init__( self._handler, identifier='bbox', version='0.2', title="Bounding box in- and out", abstract='Give bounding box, return the same', metadata=[ Metadata('Birdhouse', 'http://bird-house.github.io/'), Metadata('User Guide', 'http://emu.readthedocs.io/en/latest/') ], inputs=inputs, outputs=outputs, store_supported=True, status_supported=True)
def __init__(self): self.status_percentage_steps = dict( common_status_percentages, **{ "prepare_params": 10, "save_rdata": 90, }, ) inputs = raw_inputs outputs = [ci_output] super(ClimdexInputRaw, self).__init__( self._handler, identifier="climdex_input_raw", title="climdexInput generator (raw)", abstract= "Process for creating climdexInput object from data already ingested into R", metadata=[ Metadata("NetCDF processing"), Metadata("Climate Data Operations"), Metadata("PyWPS", "https://pywps.org/"), Metadata("Birdhouse", "http://bird-house.github.io/"), Metadata("PyWPS Demo", "https://pywps-demo.readthedocs.io/en/latest/"), ], inputs=inputs, outputs=outputs, store_supported=True, status_supported=True, )
def setUp(self): def hello(request): pass def ping(request): pass processes = [ Process( hello, 'hello', 'Process Hello', metadata=[ Metadata( 'hello metadata', 'http://example.org/hello', role= 'http://www.opengis.net/spec/wps/2.0/def/process/description/documentation' ) ]), Process(ping, 'ping', 'Process Ping', metadata=[ Metadata('ping metadata', 'http://example.org/ping') ]), ] self.client = client_for(Service(processes=processes))
def from_json(cls, json_input): instance = cls( identifier=json_input['identifier'], title=json_input.get('title'), abstract=json_input.get('abstract'), keywords=json_input.get('keywords', []), workdir=json_input.get('workdir'), metadata=[Metadata.from_json(data) for data in json_input.get('metadata', [])], data_format=Format( schema=json_input['data_format'].get('schema'), extension=json_input['data_format'].get('extension'), mime_type=json_input['data_format']['mime_type'], encoding=json_input['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 json_input['supported_formats'] ], mode=json_input.get('mode', MODE.NONE) ) instance.as_reference = json_input.get('asreference', False) if json_input.get('file'): instance.file = json_input['file'] elif json_input.get('href'): instance.url = json_input['href'] elif json_input.get('data'): instance.data = json_input['data'] return instance
def from_json(cls, json_input): instance = cls( identifier=json_input['identifier'], title=json_input['title'], abstract=json_input['abstract'], crss=json_input['crss'], keywords=json_input['keywords'], metadata=[Metadata.from_json(data) for data in json_input.get('metadata', [])], dimensions=json_input['dimensions'], workdir=json_input['workdir'], mode=json_input['mode'], min_occurs=json_input['min_occurs'], max_occurs=json_input['max_occurs'], ) instance.data = json_input['bbox'] return instance
def from_json(cls, json_input): allowed_values = [] for allowed_value in json_input['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'] )) json_input['allowed_values'] = allowed_values json_input['uoms'] = [basic.UOM(uom.get('uom')) for uom in json_input.get('uoms', [])] data = json_input.pop('data', None) uom = json_input.pop('uom', None) metadata = json_input.pop('metadata', []) json_input.pop('type') json_input.pop('any_value', None) json_input.pop('values_reference', None) instance = cls(**json_input) instance.metadata = [Metadata.from_json(d) for d in metadata] instance.data = data if uom: instance.uom = basic.UOM(uom['uom']) return instance