本文整理汇总了Python中Rule.Rule.load方法的典型用法代码示例。如果您正苦于以下问题:Python Rule.load方法的具体用法?Python Rule.load怎么用?Python Rule.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rule.Rule
的用法示例。
在下文中一共展示了Rule.load方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
# 需要导入模块: from Rule import Rule [as 别名]
# 或者: from Rule.Rule import load [as 别名]
def load(self, file, info = False):
'''
Loads employee data
@param file: a file pointer open in "rb" mode
@params info: T/F whether to print additional info while loading.
@return True if load was successful, False if any error occured
'''
try:
self.name = pickle.load(file)
print(" Loading data for %s..."%self.name)
self.priority = pickle.load(file)
if info: print(" Read priority: %d"%self.priority)
self.curShifts = pickle.load(file)
if info: print(" Read number of shifts: %d"%self.curShifts)
self.shiftsPerWeek = pickle.load(file)
if info: print(" Read shifts per week: %s"%self.shiftsPerWeek)
numRules = pickle.load(file)
if info: print(" Read number of rules: %d"%numRules)
print(" %d rules to load"%numRules)
self.rules = []
num = 0
for i in range(0,numRules):
r = Rule()
if not r.load(file, num, info):
print("\nError (%s): Loaded invalid rule, aborting..."%self.name)
return False
self.setRule(r)
num += 1
except Exception as e:
print("\nError: %s while loading %s"%(str(e), self.name))
return False
if info: print(" Finished loading data for %s"%self.name)
return True