本文整理汇总了Python中DataModel.deleteProcessedFile方法的典型用法代码示例。如果您正苦于以下问题:Python DataModel.deleteProcessedFile方法的具体用法?Python DataModel.deleteProcessedFile怎么用?Python DataModel.deleteProcessedFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataModel
的用法示例。
在下文中一共展示了DataModel.deleteProcessedFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remove_file_data
# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import deleteProcessedFile [as 别名]
def remove_file_data(global_config, session, attr_definitions, data_filename, remove_from_processed_files=False):
print 'removing data file: %s'%data_filename
competition = global_config['this_competition'] + global_config['this_season']
input_dir = './static/data/' + competition + '/ScoutingData/'
filepath = input_dir+data_filename
# Initialize the file_attributes dictionary in preparation for the
# parsing of the data file
file_attributes = {}
# Parse the data file, removing all the information in the file_attributes
# dictionary
try:
FileParser.FileParser(filepath).parse(file_attributes)
except:
raise ValueError('Error Opening File')
# The team number can be retrieved from the Team attribute, one of the
# mandatory attributes within the data file
team = file_attributes['Team']
# Also, extract the competition name, too, if it has been included in
# the data file
if file_attributes.has_key('Competition'):
competition = file_attributes['Competition']
else:
competition = global_config['this_competition'] + global_config['this_season']
if competition == None:
raise Exception( 'Competition Not Specified!')
# Loop through the attributes from the data file and post them to the
# database
for attribute, value in file_attributes.iteritems():
if value is None:
value = ''
attr_definition = attr_definitions.get_definition(attribute)
if attr_definition == None:
raise ValueError( 'No Attribute Defined For Attribute: %s' % attribute )
elif attr_definition['Database_Store']=='Yes':
DataModel.deleteAttributeValue(session, team, competition, attribute, value, attr_definition, no_throw=True)
if remove_from_processed_files:
DataModel.deleteProcessedFile(session, filepath)
score = DataModel.calculateTeamScore(session, team, competition, attr_definitions)
DataModel.setTeamScore(session, team, competition, score)