本文整理汇总了Python中pyasm.search.SearchKey.get_by_search_keys方法的典型用法代码示例。如果您正苦于以下问题:Python SearchKey.get_by_search_keys方法的具体用法?Python SearchKey.get_by_search_keys怎么用?Python SearchKey.get_by_search_keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.search.SearchKey
的用法示例。
在下文中一共展示了SearchKey.get_by_search_keys方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_search_keys [as 别名]
def execute(self):
self.search_key_list = self.kwargs.get('search_key_list')
web = WebContainer.get_web()
skip_duplicated = web.get_form_value('skip_duplicated') == 'on'
pipeline_mode = web.get_form_value('pipeline_mode')
sobjects = SearchKey.get_by_search_keys(self.search_key_list)
count = 0
offset = 0
for sobject in sobjects:
if isinstance(sobject, Task):
raise TacticException('Creation of task for [Task] is not allowed')
sk = SearchKey.get_by_sobject(sobject)
if not sobject.has_value('pipeline_code'):
#raise TacticException('Creation of task is not allowed for item with no pipeline_code attribute.')
pipeline_code = '__default__'
sobject.set_value("pipeline_code", pipeline_code)
else:
pipeline_code = sobject.get_value('pipeline_code')
input_name = '%s|task_process'% pipeline_code
contexts = []
process_names = web.get_form_values(input_name)
process_names = [name for name in process_names if name]
if pipeline_mode == 'context':
# when pipeline_mode is context, we only specify contexts
# in add_initial_tasks
contexts = process_names[:]
process_names = []
tasks = Task.add_initial_tasks(sobject, sobject.get_value('pipeline_code'),
processes=process_names, contexts=contexts, skip_duplicate=skip_duplicated, mode=pipeline_mode, start_offset=offset)
count += len(tasks)
offset += 5
self.add_description("%s Tasks added in total." % count)
示例2: get_display
# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import get_by_search_keys [as 别名]
def get_display(self):
self.check()
if self.is_refresh:
div = Widget()
else:
div = DivWdg()
self.set_as_panel(div)
div.add_style('padding','6px')
min_width = '400px'
div.add_style('min-width', min_width)
div.add_color('background','background')
div.add_class('spt_add_task_panel')
div.add_style("padding: 20px")
from tactic.ui.app import HelpButtonWdg
help_button = HelpButtonWdg(alias="creating-tasks")
div.add(help_button)
help_button.add_style("float: right")
help_button.add_style("margin-top: -5px")
if not self.search_key_list:
msg_div = DivWdg()
msg_table = Table()
msg_div.add(msg_table)
msg_table.add_row()
msg_table.add_cell( IconWdg("No items selected", IconWdg.WARNING) )
msg_table.add_cell('Please select at least 1 item to add tasks to.')
msg_div.add_style('margin: 10px')
msg_table.add_style("font-weight: bold")
div.add(msg_div)
return div
msg_div = DivWdg()
msg_div.add_style('margin-left: 4px')
div.add(msg_div, 'info')
msg_div.add('Total: %s item/s to add tasks to' %len(self.search_key_list))
div.add(HtmlElement.br())
hint = HintWdg('Tasks are added according to the assigned pipeline.')
msg_div.add(" ")
msg_div.add(hint)
msg_div.add(HtmlElement.br())
option_div = DivWdg(css='spt_ui_options')
#option_div.add_style('margin-left: 12px')
sel = SelectWdg('pipeline_mode', label='Create tasks by: ')
sel.set_option('values', ['simple process','context', 'standard'])
sel.set_option('labels', ['process','context', 'all contexts in process'])
sel.set_persistence()
sel.add_behavior({'type':'change',
'cbjs_action': 'spt.panel.refresh(bvr.src_el)'})
option_div.add(sel)
value = sel.get_value()
# default to simple process
if not value:
value = 'simple process'
msg = ''
if value not in ['simple process','context','standard']:
value = 'simple process'
if value == 'context':
msg = 'In context mode, a single task will be created for each selected context.'
elif value == 'simple process':
msg = 'In process mode, a single task will be created for each selected process.'
elif value == 'standard':
msg = 'In this mode, a task will be created for all contexts of each selected process.'
option_div.add(HintWdg(msg))
div.add(option_div)
div.add(HtmlElement.br())
title = DivWdg('Assigned Pipelines')
title.add_style('padding: 6px')
title.add_color('background','background2')
title.add_color('color','color', +120)
div.add(title)
content_div = DivWdg()
content_div.add_style('min-height', '150px')
div.add(content_div)
content_div.add_border()
filtered_search_key_list = []
for sk in self.search_key_list:
id = SearchKey.extract_id(sk)
if id=='-1':
continue
filtered_search_key_list.append(sk)
sobjects = SearchKey.get_by_search_keys(filtered_search_key_list)
skipped = []
pipeline_codes = []
for sobject in sobjects:
if isinstance(sobject, Task):
#.........这里部分代码省略.........