本文整理汇总了Python中pyasm.search.SearchType.get_columns方法的典型用法代码示例。如果您正苦于以下问题:Python SearchType.get_columns方法的具体用法?Python SearchType.get_columns怎么用?Python SearchType.get_columns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.search.SearchType
的用法示例。
在下文中一共展示了SearchType.get_columns方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copy_sobject
# 需要导入模块: from pyasm.search import SearchType [as 别名]
# 或者: from pyasm.search.SearchType import get_columns [as 别名]
def copy_sobject(my, sobject, dst_search_type, context=None, checkin_mode='inplace'):
new_sobject = SearchType.create(dst_search_type)
search_type = SearchType.get(dst_search_type)
columns = SearchType.get_columns(dst_search_type)
data = sobject.get_data()
for name, value in data.items():
if name in ['id','pipeline_code']:
continue
if name not in columns:
continue
if not value:
continue
if name == "code":
value = Common.get_next_sobject_code(sobject, 'code')
if not value:
continue
new_sobject.set_value(name, value)
if SearchType.column_exists(dst_search_type, "project_code"):
project_code = Project.get_project_code()
new_sobject.set_value("project_code", project_code)
new_sobject.commit()
# get all of the current snapshots and file paths associated
if not context:
snapshots = Snapshot.get_all_current_by_sobject(sobject)
else:
snapshots = [Snapshot.get_current_by_sobject(sobject, context)]
if not snapshots:
return
msgs = []
for snapshot in snapshots:
#file_paths = snapshot.get_all_lib_paths()
file_paths_dict = snapshot.get_all_paths_dict()
file_types = file_paths_dict.keys()
if not file_types:
continue
# make sure the paths match the file_types
file_paths = [file_paths_dict.get(x)[0] for x in file_types]
mode = checkin_mode
# checkin the files (inplace)
try:
context = snapshot.get_value('context')
checkin = FileCheckin(new_sobject, context=context, file_paths=file_paths, file_types=file_types, mode=mode)
checkin.execute()
#print "done: ", context, new_sobject.get_related_sobjects("sthpw/snapshot")
except CheckinException, e:
msgs.append('Post-process Check-in Error for %s: %s ' %(context, e.__str__()))
示例2: on_insert
# 需要导入模块: from pyasm.search import SearchType [as 别名]
# 或者: from pyasm.search.SearchType import get_columns [as 别名]
def on_insert(my):
'''Function that should be run on insert/update. It's already automatically called during insert.
On update, the caller needs to call this explicitly. It checks the search type
this pipeline is associated with and if there is no pipeline code
column, then update it. It updates the process table also.'''
search_type = my.get_value('search_type')
my.update_process_table(search_type=search_type)
# don't do anything for task sType
if search_type =='sthpw/task':
return
if not search_type:
return
if ProdSetting.get_value_by_key('autofill_pipeline_code') != 'false':
try:
columns = SearchType.get_columns(search_type)
if not 'pipeline_code' in columns:
# add the pipeline code column
from pyasm.command import ColumnAddCmd
cmd = ColumnAddCmd(search_type, "pipeline_code", "varchar")
cmd.execute()
except SqlException, e:
print "Error creating column [pipeline_code] for %" %search_type
pass
# go through all of the sobjects and set all the empty ones
# to the new pipeline
search = Search(search_type)
search.add_op("begin")
search.add_filter("pipeline_code", "NULL", op='is', quoted=False)
search.add_filter("pipeline_code", "")
search.add_op("or")
sobject_ids = search.get_sobject_ids()
if sobject_ids:
# this is much faster and memory efficient
db_resource = SearchType.get_db_resource_by_search_type(search_type)
sql = DbContainer.get(db_resource)
tbl = search.get_table()
sobject_ids = [str(x) for x in sobject_ids]
pipeline_code = my.get_value("code")
sql.do_update('''UPDATE "%s" SET "pipeline_code" = '%s' WHERE id in (%s) ''' %(tbl, pipeline_code, ','.join(sobject_ids)))
"""
示例3: check
# 需要导入模块: from pyasm.search import SearchType [as 别名]
# 或者: from pyasm.search.SearchType import get_columns [as 别名]
def check(my):
#search_type_obj = SearchType.get(my.search_type)
columns = SearchType.get_columns(my.search_type)
if my.attr_name not in columns:
raise TacticException('[%s] does not exist in this table [%s]'%(my.attr_name, my.search_type))
return True
示例4: get_first_row_wdg
# 需要导入模块: from pyasm.search import SearchType [as 别名]
# 或者: from pyasm.search.SearchType import get_columns [as 别名]
#.........这里部分代码省略.........
option_div_top.add_color('background','background', -5)
option_div_top.add_style("padding: 10px")
option_div_top.add_border()
option_div_top.add_style("width: 300px")
swap = SwapDisplayWdg(title="Parsing Options")
option_div_top.add(swap)
option_div_top.add_style("margin-right: 30px")
my.search_type_obj = SearchType.get(my.search_type)
option_div = DivWdg()
swap.set_content_id(option_div.set_unique_id() )
option_div.add_style("display: none")
option_div.add_style('margin-left: 14px')
option_div.add_style('margin-top: 10px')
option_div.add_style("font-weight: bold")
option_div_top.add(option_div)
# first row and second row
#option_div.add( HtmlElement.br() )
option_div.add(SpanWdg("Use Title Row: ", css='small'))
title_row_checkbox = CheckboxWdg("has_title")
title_row_checkbox.set_default_checked()
title_row_checkbox.add_behavior({'type' : 'click_up',
'propagate_evt': 'true',
'cbjs_action': "spt.panel.refresh('preview_data',\
spt.api.Utility.get_input_values('csv_import_main'))"})
option_div.add(title_row_checkbox)
option_div.add( HintWdg("Set this to use the first row as a title row to match up columns in the database") )
option_div.add( HtmlElement.br(2) )
option_div.add(SpanWdg("Use Lowercase Title: ", css='small'))
lower_title_checkbox = CheckboxWdg("lowercase_title")
lower_title_checkbox.add_behavior({'type' : 'click_up',
'propagate_evt': 'true',
'cbjs_action': "spt.panel.refresh('preview_data',\
spt.api.Utility.get_input_values('csv_import_main'))"})
option_div.add(lower_title_checkbox)
option_div.add( HtmlElement.br(2) )
option_div.add(SpanWdg("Sample Data Row: ", css='small'))
data_row_text = SelectWdg("data_row")
data_row_text.set_option('values', '1|2|3|4|5')
data_row_text.set_value('1')
data_row_text.add_behavior({'type' : 'change',
'cbjs_action': "spt.panel.refresh('preview_data',\
spt.api.Utility.get_input_values('csv_import_main'))"})
option_div.add(data_row_text)
option_div.add( HintWdg("Set this as a sample data row for display here") )
option_div.add( HtmlElement.br(2) )
# encoder
option_div.add(SpanWdg("Encoder: ", css='small'))
select_wdg = SelectWdg('encoder')
select_wdg.set_option('values', ['','utf-8', 'iso_8859-1'])
select_wdg.set_option('labels', ['ASCII (default)','UTF-8','Excel ISO 8859-1'])
select_wdg.add_behavior({'type' : 'change',
'cbjs_action': "spt.panel.refresh('preview_data',\
spt.api.Utility.get_input_values('csv_import_main'))"})
option_div.add(select_wdg)
option_div.add( HtmlElement.br(2) )
option_div.add(SpanWdg("Identifying Column: ", css='small'))
select_wdg = SelectWdg('id_col')
select_wdg.set_option('empty','true')
#columns = my.search_type_obj.get_columns()
columns = SearchType.get_columns(my.search_type)
# make sure it starts off with id, code where applicable
if 'code' in columns:
columns.remove('code')
columns.insert(0, 'code')
if 'id' in columns:
columns.remove('id')
columns.insert(0, 'id')
select_wdg.set_option('values', columns)
option_div.add(select_wdg)
option_div.add( HintWdg("Set which column to use for identifying an item to update during CSV Import") )
option_div.add( HtmlElement.br(2) )
div.add(option_div_top)
my.has_title = title_row_checkbox.is_checked()
# need to somehow specify defaults for columns
div.add(my.get_preview_wdg())
return div