本文整理汇总了Python中WebCommonUtils.split_comp_str方法的典型用法代码示例。如果您正苦于以下问题:Python WebCommonUtils.split_comp_str方法的具体用法?Python WebCommonUtils.split_comp_str怎么用?Python WebCommonUtils.split_comp_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebCommonUtils
的用法示例。
在下文中一共展示了WebCommonUtils.split_comp_str方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_debrief_files
# 需要导入模块: import WebCommonUtils [as 别名]
# 或者: from WebCommonUtils import split_comp_str [as 别名]
def process_debrief_files(global_config, input_dir, recursive=True):
# Initialize the database session connections
issues_db_name = global_config['issues_db_name'] + global_config['this_season']
debrief_db_name = global_config['debriefs_db_name'] + global_config['this_season']
debrief_session = DbSession.open_db_session(debrief_db_name)
issues_session = DbSession.open_db_session(issues_db_name)
# Create the database if it doesn't already exist
#if not os.path.exists('./' + db_name):
# DebriefDataModel.create_db_tables(my_db)
# The following regular expression will select all files that conform to
# the file naming format Debrief*.txt. Build a list of all datafiles that match
# the naming format within the directory passed in via command line
# arguments.
file_regex = re.compile('Debrief[a-zA-Z0-9_-]+.txt')
files = get_files(global_config, debrief_session, debrief_db_name, input_dir, file_regex, recursive)
# Process data files
for data_filename in files:
print 'processing %s'%data_filename
try:
# Initialize the debrief_attributes dictionary in preparation for the
# parsing of the data file
debrief_attributes = {}
# Parse the data file, storing all the information in the attributes
# dictionary
FileParser.FileParser(data_filename).parse(debrief_attributes)
DebriefDataModel.addDebriefFromAttributes(debrief_session, debrief_attributes)
# Also, extract the competition name, too, if it has been included in
# the data file
if debrief_attributes.has_key('Competition'):
competition = debrief_attributes['Competition']
issue_base_name = WebCommonUtils.split_comp_str(competition)[0]
else:
competition = global_config['this_competition'] + global_config['this_season']
issue_base_name = global_config['this_competition']
if competition == None:
raise Exception( 'Competition Not Specified!')
# At competition, we will likely have multiple laptops manging the data, but we want
# only one machine to be responsible for the issues database. In all likelihood,
# that machine will be the one in the pits, or possibly the application running
# in the cloud.
if global_config['issues_db_master'] == 'Yes':
match_id = debrief_attributes['Match']
submitter = debrief_attributes['Scouter']
timestamp = str(int(time.time()))
subgroup = 'Unassigned'
status = 'Open'
owner = 'Unassigned'
if debrief_attributes.has_key('Issue1_Summary') or debrief_attributes.has_key('Issue1_Description'):
# look to see if there is already a debrief issue, and if so, do not attempt to create/update
# an issue, as there are already other issue files that would then conflict with this one
issue_key = 'Issue1'
if DebriefDataModel.getDebriefIssue(debrief_session, competition, match_id, issue_key) == None:
# if no summary is provided, then use the description as the summary. Likewise, if no description
# is provided then use the summary as the description. Keep in mind that we need at least the
# summary or description to be provided.
if debrief_attributes.has_key('Issue1_Summary'):
summary = debrief_attributes['Issue1_Summary']
else:
summary = debrief_attributes['Issue1_Description']
if debrief_attributes.has_key('Issue1_Description'):
description = debrief_attributes['Issue1_Description']
else:
description = debrief_attributes['Issue1_Summary']
if debrief_attributes.has_key('Issue1_Priority'):
priority = debrief_attributes['Issue1_Priority']
else:
priority = 'Priority_3'
if debrief_attributes.has_key('Issue1_Taskgroup'):
component = debrief_attributes['Issue1_Taskgroup']
else:
component = ''
debrief_key = str(match_id) + '_' + issue_key
issue_id = IssueTrackerDataModel.getIssueId(issues_session, issue_base_name)
issue = IssueTrackerDataModel.addOrUpdateIssue(issues_session, issue_id, summary, status, priority,
subgroup, component, submitter, owner, description, timestamp, debrief_key)
if issue != None:
issue.create_file('./static/data/%s/ScoutingData' % competition)
DebriefDataModel.addOrUpdateDebriefIssue(debrief_session, match_id, competition, issue_id, issue_key)
if debrief_attributes.has_key('Issue2_Summary') or debrief_attributes.has_key('Issue2_Description'):
# look to see if there is already a debrief issue, and if so, do not attempt to create/update
# an issue, as there are already other issue files that would then conflict with this one
issue_key = 'Issue2'
if DebriefDataModel.getDebriefIssue(debrief_session, competition, match_id, issue_key) == None:
# if no summary is provided, then use the description as the summary. Likewise, if no description
# is provided then use the summary as the description. Keep in mind that we need at least the
#.........这里部分代码省略.........