Beispiel #1
0
def handle_task(tool, tool_name, en_str, _keywords, des):
    config = OWLUtils.get_config(module_path + '/config.ini')
    tasks = config.options('task')
    for task_item in tasks:
        # print(task_item)
        if task_item in _keywords:
            task_cls = config.get('task', task_item)
            # print(task_cls)
            short_name = tool_name.split('.', maxsplit=1)[0]
            task_name = config.get(
                'tools', short_name) + '_' + tool_name.split('.',
                                                             maxsplit=1)[1]
            task_name = task_name.replace('.', '_')
            # avoid duplicate
            if not task[task_name + "_task"]:
                task_ins = task[task_cls](task_name + "_task",
                                          prefLabel=locstr(en_str + " task",
                                                           lang='en'))
                task_ins.description.append(locstr(des, lang='en'))
                task_ins.identifier = task_name
                task_ins.isAtomicTask = True
            else:
                task_ins = task[task_name + "_task"]
            if (task_ins in tool.usedByTask) is False:
                tool.usedByTask.append(task_ins)
            if (tool in tool.processingTool) is False:
                task_ins.processingTool.append(tool)
Beispiel #2
0
def get_task_class(tool_name):
	config = OWLUtils.get_config(module_path + '/config.ini')
	tool_cls = ''  # only one
	for k, v in config.items('task'):
		if tool_name in v:
			tool_cls = k
	return tool_cls
Beispiel #3
0
def get_format(option):
    """
	get mapping format
	对应的数据格式
	"""
    config = OWLUtils.get_config(module_path + '/config.ini')
    _prop = OWLUtils.get_option(config, 'format', option)
    return _prop
Beispiel #4
0
def topic_classes():
    config = OWLUtils.get_config(module_path + '/config.ini')
    for k, v in config.items('application'):
        k = Preprocessor.to_upper_camel_case(k, True)
        topic_cls = OWLUtils.create_onto_class(onto, k, TopicCategoryTool)
        for _tool in v.split(','):
            _tool = _tool.strip()
            if onto[_tool] is not None:
                onto[_tool].is_a.append(topic_cls)
Beispiel #5
0
def handle_applcation():
    config = OWLUtils.get_config(module_path + '/config.ini')
    for k, v in config.items('application'):
        for _tool in v.split(','):
            _tool = _tool.strip()
            tools = [_tool]
            if str(_tool).endswith('*'):
                tools = onto.search(iri=module_uri + '#' + _tool)
            for __tool in tools:
                if onto[__tool] is not None:
                    OWLUtils.application_category(onto[__tool], [], k, [])
Beispiel #6
0
def handle_task(tool, task_name, des):
	config = OWLUtils.get_config(module_path + '/config.ini')
	category = tool_class(task_name)
	task_cls = config.get('task', category.name)
	task_name = Preprocessor.space_2_underline(task_name.replace(".py", ""))
	if not task[task_name + "_task"]:
		task_ins = task[task_cls](task_name + "_task", prefLabel=locstr(task_name + " task", lang='en'))
		task_ins.isAtomicTask = True
		task_ins.identifier = task_name
	else:
		task_ins = task[task_name + "_task"]
	if (task_ins in tool.usedByTask) is False:
		tool.usedByTask.append(task_ins)
	if (tool in tool.processingTool) is False:
		task_ins.processingTool.append(tool)
	task_ins.description.append(locstr(des, lang='en'))
Beispiel #7
0
def get_property(option, prop_type):
    """
		根据配置查找对应的属性,没有则创建新的属性

	Args:
		option: property name
		prop_type: ObjectProperty or DataProperty

	Returns: created property name

	"""
    config = OWLUtils.get_config(module_path + '/config.ini')
    _prop = OWLUtils.get_option(config, 'saga', option)
    if _prop is None:
        if onto.__getattr__(option) is None:
            OWLUtils.create_onto_class(onto, option, prop_type)
        return option
    else:
        return _prop
Beispiel #8
0
def handle_task(tool, category, task_name, des):
	config = OWLUtils.get_config(module_path + '/config.ini')
	if re.match("(^GIS Analysis )", category):
		category = 'GIS Analysis'
	elif re.match("(^Image Processing Tools )", category):
		category = 'Image Processing Tools'
	task_cls = config.get('task', category)
	i_task_name = task_name.replace(' ', '_')
	if not task[i_task_name + "_task"]:
		task_ins = task[task_cls](i_task_name + "_task", prefLabel=locstr(task_name + " task", lang='en'))
		task_ins.isAtomicTask = True
		task_ins.identifier = i_task_name
	else:
		task_ins = task[i_task_name + "_task"]
	if (task_ins in tool.usedByTask) is False:
		tool.usedByTask.append(task_ins)
	if (tool in tool.processingTool) is False:
		task_ins.processingTool.append(tool)
	task_ins.description.append(locstr(des, lang='en'))
Beispiel #9
0
def get_property(option, prop_type):
	"""
		根据配置查找对应的属性,没有则创建新的属性

	Args:
		option: property name
		prop_type: ObjectProperty or DataProperty

	Returns: created property name

	"""
	config = OWLUtils.get_config(module_path + '/config.ini')
	_prop = OWLUtils.get_option(config, 'taudem', option)
	# 返回配置的属性或是已有的属性(has[Name])
	if _prop is not None:
		return _prop
	else:
		_prop = gb.__getattr__(option)
		if _prop is None:
			OWLUtils.create_onto_class(onto, option, prop_type)
	return option
Beispiel #10
0
def handle_task(tool, full_name, task_name, des):
    config = OWLUtils.get_config(module_path + '/config.ini')
    task_type = get_task_type(full_name)
    task_cls = config.get('task', task_type)
    # tool.keywords.append(task_type)
    tool.subject.append(task_type)
    # avoid duplicate
    if not task[task_name + "_task"]:
        task_ins = task[task_cls](task_name + "_task",
                                  prefLabel=locstr(
                                      task_name.replace('_', ' ') + " task",
                                      lang='en'))
        task_ins.isAtomicTask = True
        task_ins.identifier = task_name
    else:
        task_ins = task[task_name + "_task"]
    if (task_ins in tool.usedByTask) is False:
        tool.usedByTask.append(task_ins)
    if (tool in tool.processingTool) is False:
        task_ins.processingTool.append(tool)
    task_ins.description.append(locstr(des, lang='en'))
Beispiel #11
0
def handle_task(tool, tool_name, en_str, _keywords, desc):
    config = OWLUtils.get_config(module_path + '/config.ini')
    tasks = config.options('task')
    for task_item in tasks:
        # print(task_item)
        if task_item in _keywords:
            task_cls = config.get('task', task_item)
            task_name = Preprocessor.task_name(tool_name)
            if task[task_name] is None:
                task_ins = task[task_cls](
                    task_name,
                    prefLabel=locstr(en_str.replace('Tool', '') + " task",
                                     lang='en'))
                # task_ins = task[task_cls](tool_name + "_task", prefLabel=locstr(en_str.replace('Tool', '') + " task", lang='en'))
                task_ins.description.append(locstr(desc, lang='en'))
                task_ins.isAtomicTask = True
                task_ins.identifier = task_name
            else:
                task_ins = task[task_name]
            if (task_ins in tool.usedByTask) is False:
                tool.usedByTask.append(task_ins)
            if (tool in tool.processingTool) is False:
                task_ins.processingTool.append(tool)
Beispiel #12
0
def get_format(option):
	config = OWLUtils.get_config(module_path + '/config.ini')
	_prop = OWLUtils.get_option(config, 'format', option)
	return _prop
Beispiel #13
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author: houzhiwei
# time: 2019/8/20 21:28
import os
from JSON2OWL.OwlConvert.OwlUtils import OWLUtils

module_path = os.path.dirname(__file__)

config = OWLUtils.get_config(module_path + '/config.ini')
for k, v in config.items('application'):
    # print(k)
    print(type(v.split(',')))
Beispiel #14
0
def tool_class(tool_name):
    short_name = tool_name.split('.', maxsplit=1)[0]
    config = OWLUtils.get_config(module_path + '/config.ini')
    tool_cls = str(config.get('tools', short_name)).capitalize() + 'Tool'
    return OWLUtils.create_onto_class(onto, tool_cls, StandardCategoryTool)