本文整理汇总了Python中zope.app.annotation.interfaces.IAnnotations.remove方法的典型用法代码示例。如果您正苦于以下问题:Python IAnnotations.remove方法的具体用法?Python IAnnotations.remove怎么用?Python IAnnotations.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zope.app.annotation.interfaces.IAnnotations
的用法示例。
在下文中一共展示了IAnnotations.remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LoggerSection
# 需要导入模块: from zope.app.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.app.annotation.interfaces.IAnnotations import remove [as 别名]
class LoggerSection(object):
classProvides(ISectionBlueprint)
implements(ISection)
def __init__(self, transmogrifier, name, options, previous):
self.transmogrifier = transmogrifier
keys = options.get('keys') or ''
self.pathkey = options.get('path-key', '_path').strip()
self.keys = Matcher(*keys.splitlines())
self.previous = previous
self.logger = name
self.storage = IAnnotations(transmogrifier).setdefault(VALIDATIONKEY, [])
def __iter__(self):
start_time = time()
count = 0
problematic = 0
for item in self.previous:
# source sections add store path of current generated item in annotation
# it gives posibility to monitor what items go through all pipeline
# sections between source section and this section and what don't
if self.pathkey in item and item[self.pathkey] in self.storage:
self.storage.remove(item[self.pathkey])
count += 1
# print item data stored on keys given as option
items = []
for key in item.keys():
if self.keys(key)[0] is not None:
items.append("%s=%s" % (key, item[key]))
if items:
msg = ", ".join(items)
logging.getLogger(self.logger).info(msg)
yield item
working_time = int(round(time() - start_time))
# log items that maybe have some problems
if self.storage:
problematic = len(self.storage)
logging.getLogger(self.logger).warning('\nNext objects didn\'t go through full pipeline:\n%s' % \
'\n'.join(['\t'+i for i in self.storage]))
# delete validation data from annotations
anno = IAnnotations(self.transmogrifier)
if VALIDATIONKEY in anno:
del anno[VALIDATIONKEY]
seconds = working_time % 60
minutes = working_time / 60 % 60
hours = working_time / 3600
stats = "\nPipeline processing time: %02d:%02d:%02d\n" % (hours, minutes, seconds)
stats += "\t%4d items were generated in source sections\n" % (count + problematic)
stats += "\t%4d went through full pipeline\n" % count
stats += "\t%4d were discarded in some section" % problematic
logging.getLogger(self.logger).info(stats)