本文整理汇总了Python中pyasm.search.SearchKey.extract_id方法的典型用法代码示例。如果您正苦于以下问题:Python SearchKey.extract_id方法的具体用法?Python SearchKey.extract_id怎么用?Python SearchKey.extract_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.search.SearchKey
的用法示例。
在下文中一共展示了SearchKey.extract_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check
# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import extract_id [as 别名]
def check(my):
if my.mode == 'export_matched':
from tactic.ui.panel import TableLayoutWdg
table = TableLayoutWdg(search_type=my.search_type, view=my.view,\
show_search_limit='false', search_limit=-1, search_view=my.search_view,\
search_class=my.search_class, simple_search_view=my.simple_search_view, init_load_num=-1)
table.handle_search()
search_objs = table.sobjects
my.selected_search_keys = SearchKey.get_by_sobjects(search_objs, use_id=True)
return True
for sk in my.input_search_keys:
st = SearchKey.extract_search_type(sk)
if st not in my.search_type_list:
my.search_type_list.append(st)
id = SearchKey.extract_id(sk)
if id == '-1':
continue
my.selected_search_keys.append(sk)
if len(my.search_type_list) > 1:
my.check_passed = False
my.error_msg = 'More than 1 search type is selected. Please keep the selection to one type only.'
return False
if not my.search_type_list and my.mode == 'export_selected':
my.check_passed = False
my.error_msg = 'Search type cannot be identified. Please select a valid item.'
return False
return True
示例2: _test_dir_naming
# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import extract_id [as 别名]
def _test_dir_naming(my):
# change to the test dir naming class
my.sobj.set_value('dir_naming_cls', 'pyasm.biz.naming_test.TestDirNaming')
my.sobj.commit()
# 1. try a different search_type unittest/person
version = 9
code = 'phil2'
process = 'model'
type = 'main'
context = 'modeling'
asset = SearchType.create( 'unittest/person' )
asset.set_value("code",code)
asset.set_value("name_first", "Philip")
asset.commit()
# change a different input file name
file_obj = File(File.SEARCH_TYPE)
# due to new restriction of set_sobject_value().. we can't use it any more
#file_obj.set_sobject_value(asset)
sk = SearchKey.get_by_sobject(asset, use_id =True)
st = SearchKey.extract_search_type(sk)
sid = SearchKey.extract_id(sk)
file_obj.set_value('search_type', st)
file_obj.set_value('search_id', sid)
file_obj.set_value('file_name','some_maya_model.mb')
file_obj.set_value('type', type)
file_obj.set_value('base_type', 'file')
file_obj.commit()
virtual_snapshot = Snapshot.create_new()
virtual_snapshot_xml = '<snapshot process=\'%s\'><file type=\'%s\' file_code=\'%s\'/></snapshot>' % (process, type, file_obj.get_code())
virtual_snapshot.set_value("snapshot", virtual_snapshot_xml)
virtual_snapshot.set_value("context", context)
virtual_snapshot.set_sobject(asset)
virtual_snapshot.set_value("version", version)
Project.set_project('unittest')
dir_naming = Project.get_dir_naming()
dir_naming.set_sobject(asset)
dir_naming.set_snapshot(virtual_snapshot)
dir_naming.set_file_object(file_obj)
dir_name = dir_naming.get_dir()
expected_dir_name = '/assets/phil2/mb.main/v009'
expected_dir_name2 = '/phil2/mb.main/v009'
my.assertEquals(expected_dir_name, dir_name)
lib_paths = virtual_snapshot.get_all_lib_paths()
sand_paths = virtual_snapshot.get_all_lib_paths(mode='sandbox')
client_paths = virtual_snapshot.get_all_lib_paths(mode='client_repo')
base_dir = Config.get_value("checkin", "asset_base_dir", sub_key='default')
sand_base_dir = dir_naming.get_base_dir(protocol='sandbox')
client_base_dir = dir_naming.get_base_dir(protocol='client_repo')
my.assertEquals(lib_paths[0].startswith('%s%s'%(base_dir, expected_dir_name2)), True)
my.assertEquals(sand_paths[0].startswith('%s%s'%(sand_base_dir[0], expected_dir_name2)), True)
my.assertEquals(client_paths[0].startswith('%s%s'%(client_base_dir[0], expected_dir_name2)), True)
# 2 get_preallocated_path
# set version 1 here since it's the first snapshot for this sobject.
# without a virtual file_object, the file_name is empty, and so the dir ma.maya is now .maya
my.assertEquals("phil/.maya/v001", my.get_preallocated_dir())
# switch back to regular file naming
my.sobj.set_value('file_naming_cls', 'pyasm.biz.naming_test.TestFileNaming')
my.sobj.commit()
my.assertEquals("phil/ma.maya/v001", my.get_preallocated_dir())
示例3: get_display
# 需要导入模块: from pyasm.search import SearchKey [as 别名]
# 或者: from pyasm.search.SearchKey import extract_id [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):
#.........这里部分代码省略.........