Example #1
0
def handle_parameters(tool, param, _onto):
    # 部分parameter不包含isInputFile等属性
    name = param['parameter']
    _name = Preprocessor.io_name(param['parameter'], _onto, ['overwrite'])
    if 'isInputFile' in param.keys() and param['isInputFile']:
        p = GrassInput(_name, prefLabel=locstr(name, lang='en'))
        # p = GrassInput(0, prefLabel=locstr(name, lang='en'))
        tool.input.append(p)
        p.isInput = param['isInputFile']
        OWLUtils.link_to_domain_concept(p, name.replace('_', ' '))
    elif 'isOutputFile' in param.keys() and param['isOutputFile']:
        p = GrassOutput(_name, prefLabel=locstr(name, lang='en'))
        # p = GrassOutput(0, prefLabel=locstr(name, lang='en'))
        tool.output.append(p)
        p.isOutput = param['isOutputFile']
        OWLUtils.link_to_domain_concept(p, name.replace('_', ' '))
    else:
        p = GrassOption(_name, prefLabel=locstr(name, lang='en'))
        # p = GrassOption(0, prefLabel=locstr(name, lang='en'))
        tool.option.append(p)
    p.flag = param['flag']
    p.identifier = name
    if 'dataType' in param.keys():
        p.datatypeInString.append(param['dataType'])
        p.datatype.append(OWLUtils.get_datatype_iris(param['dataType']))
    p.description.append(param['explanation'])
    if 'defaultValue' in param.keys():
        if param['defaultValue'] is not None:
            p.defaultValue = param['defaultValue']
    p.isOptional = param['isOptional']
    if 'alternatives' in param.keys():
        alternatives = param['alternatives']
        if alternatives:
            literal = True
            if param['explanation'] == "Name of Modules":
                literal = False
            if len(alternatives) > 1:
                _onto, l = OWLUtils.resources_2_rdf_list(
                    _onto, alternatives, literal)
                p.availableList.append(l)
                for value in alternatives:
                    p.availableValue.append(value)
            else:
                if re.match('[-0-9]+-[0-9]+', alternatives[0]):
                    p.minimum = alternatives[0].rsplit('-', 1)[0]
                    p.maximum = alternatives[0].rsplit('-', 1)[1]
                elif re.match('[-0-9]+-[a-zA-Z<> ]+', alternatives[0]):
                    p.minimum = alternatives[0].split('-')[0]
                p.comment.append('Options: ' + ' '.join(alternatives))
Example #2
0
def handle_options(tool, param, _onto):
	pname = param['name']
	_name = Preprocessor.io_name(pname, _onto, common_options)
	p = GDALOption(_name, prefLabel=locstr(pname, lang='en'))
	p.identifier = pname
	if param['flag']: p.flag = param['flag']
	p.isOptional = param['isOptional']
	p.description.append(locstr(param['explanation'], lang='en'))
	p.datatype.append(OWLUtils.get_datatype_iris(param['dataType']))
	if "available_values" in param.keys():
		for value in param['available_values']:
			p.availableValue.append(value)
		onto, _list = OWLUtils.resources_2_rdf_list(_onto, param['available_values'])
		p.availableList.append(_list)
	if "available_choices" in param.keys():
		p, onto = OWLUtils.handle_choices(p, pname, param['available_choices'], GDALAvailableChoice, _onto)
	if "input_pattern" in param.keys():
		p.inputPattern.append(param['input_pattern'])
	tool.option.append(p)