本文整理汇总了Python中pyasm.search.SearchType.get_tactic_type方法的典型用法代码示例。如果您正苦于以下问题:Python SearchType.get_tactic_type方法的具体用法?Python SearchType.get_tactic_type怎么用?Python SearchType.get_tactic_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.search.SearchType
的用法示例。
在下文中一共展示了SearchType.get_tactic_type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from pyasm.search import SearchType [as 别名]
# 或者: from pyasm.search.SearchType import get_tactic_type [as 别名]
def execute(self):
column = self.get_option("column")
if not column:
column = self.name
# get the value
# NOTE: not sure why this was "column". The value will come
# through with the name of the element. The "column" options
# tells the action which column to set the value to
#value = self.get_value(column)
value = self.get_value(self.name)
# check if there is an expression on the update
expr = self.get_option("expression")
# check for parent action to save search_type and search_id or parent_code etc separately
# this is usually already taken care of in EditCmd
parent_key_action = self.get_option('parent_key') == 'true'
if expr:
vars = {
'VALUE': value
}
Search.eval(expr, self.sobject, vars=vars)
else:
search_type = self.sobject.get_search_type()
col_type = SearchType.get_tactic_type(search_type, column)
value = self.convert_value(col_type, value)
if value == None:
pass
elif parent_key_action:
self.sobject.add_relationship(value)
else:
self.sobject.set_value(column, value )
if self.commit_flag == True:
self.sobject.commit()
示例2: is_new_group
# 需要导入模块: from pyasm.search import SearchType [as 别名]
# 或者: from pyasm.search.SearchType import get_tactic_type [as 别名]
def is_new_group(self, prev_sobj, sobj):
'''check if this task belong to a new parent '''
if not prev_sobj:
return True
# let the widget determine if it is new
is_new = self.widget.is_new_group(prev_sobj, sobj)
if is_new != None:
return is_new
# if it is None, use the default
prev_value = prev_sobj.get_value(self.column)
sobj_value = sobj.get_value(self.column, no_exception=True)
# Now check for timestamp values and if found group by each calendar day (as default behavior),
# otherwise you get one grouping for each row if the time part of the timestamp is not the same ...
#
st = sobj.get_search_type()
value_type = SearchType.get_tactic_type(st, self.column)
if value_type == 'timestamp':
from dateutil import parser
prev_date = parser.parse(prev_value) # returns a datetime object
sobj_date = parser.parse(sobj_value) # returns a datetime object
prev_value = "%s-%s-%s" % (prev_date.year, str(prev_date.month).zfill(2), str(prev_date.day).zfill(2))
sobj_value = "%s-%s-%s" % (sobj_date.year, str(sobj_date.month).zfill(2), str(sobj_date.day).zfill(2))
# compare search key here
if prev_value == sobj_value:
return False
else:
return True