本文整理汇总了Python中pyasm.search.Search.set_show_retired_flag方法的典型用法代码示例。如果您正苦于以下问题:Python Search.set_show_retired_flag方法的具体用法?Python Search.set_show_retired_flag怎么用?Python Search.set_show_retired_flag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.search.Search
的用法示例。
在下文中一共展示了Search.set_show_retired_flag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_next_num
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import set_show_retired_flag [as 别名]
def _get_next_num(my, columns):
# set the default
code_num = 1
# get the highest number, extract the number and increase by 1
search_type = my.sobject.get_search_type()
search = Search(search_type)
search.set_show_retired_flag(True)
for column in columns:
value = my.sobject.get_value(column)
search.add_filter(column, value)
# order by descending codes
search.add_order_by("code desc")
sobject = search.get_sobject()
if sobject != None:
code = sobject.get_value("code")
naming = Project.get_code_naming(sobject, code)
code_num = naming.get_match("padding")
code_num = int(code_num) + 1
return code_num
示例2: _get_next_num
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import set_show_retired_flag [as 别名]
def _get_next_num(sobject, column):
from pyasm.search import Search
# assumptions: a code would look something like this asset_001
# the only numbers that we care about are the trailing ones
'''
To get the next number, first do a search for
Order code by desc (code starts with asset_)
get a count of the search
grab the first result of the search. Get it's trailing number
the number to be returned will is whichever is bigger of the count or the trailing number
if ther is a number for neither, then return 1.
'''
# set the default start value
code_num = Common._get_start_code()
# get the highest number, extract the number and increase by 1
search_type = sobject.get_search_type()
search = Search(search_type)
search.set_show_retired_flag(True)
value = sobject.get_value(column)
startswith_value = value.rstrip("0123456789")
# if column is code, then value is the code
'''
There are two cases in which startswith_value would be an empty string
either there was no code to begin with, or the code is all numbers
if there is no code, don't do a search.
if there are only numbers, go off of the numbers
ie: if the code is 403. The return code should be 403_001
'''
do_search = True
if not startswith_value:
# if there is no code
if not value:
do_search = False
# if code is all numbers
else:
startswith_value = value
if do_search:
search.add_filter(column, "%s%%" % (startswith_value), op='LIKE')
else:
return None
# order by descending codes
search.add_order_by("code desc")
last_sobject = search.get_sobject()
count = search.get_count()
# grab the first result of the search. Get it's trailing number
if last_sobject != None:
last_sobject_code = last_sobject.get_value("code")
last_sobject_code_num = last_sobject_code.lstrip(startswith_value)
last_sobject_code_num = re.sub("[^0-9]", "", last_sobject_code_num)
# if last_sobject_code_num doesn't exist, then set it to 0
# if it does, make sure that it's an int
if not last_sobject_code_num:
last_sobject_code_num = 0
else:
last_sobject_code_num = int(last_sobject_code_num)
# the number to be returned will is whichever is bigger of the count or the trailing number
if int(count) > int(last_sobject_code_num):
code_num = int(count) - 1
'''
count is subtracted by 1 because there are two cases
either the code starts with something like asset, or asset_001
if it starts off as asset, then it's the same as starting from 0
if it starts with 001 though, then it's fine, because it'll take the 001 instead
'''
else:
code_num = last_sobject_code_num
# increase the larger number by 1
code_num = code_num + 1
return code_num