本文整理汇总了Python中waflib.Utils.lru_cache方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.lru_cache方法的具体用法?Python Utils.lru_cache怎么用?Python Utils.lru_cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waflib.Utils
的用法示例。
在下文中一共展示了Utils.lru_cache方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cached_find_resource
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import lru_cache [as 别名]
def cached_find_resource(self, node, filename):
"""
Find a file from the input directory
:param node: directory
:type node: :py:class:`waflib.Node.Node`
:param filename: header to find
:type filename: string
:return: the node if found, or None
:rtype: :py:class:`waflib.Node.Node`
"""
try:
cache = node.ctx.preproc_cache_node
except AttributeError:
cache = node.ctx.preproc_cache_node = Utils.lru_cache(FILE_CACHE_SIZE)
key = (node, filename)
try:
return cache[key]
except KeyError:
ret = node.find_resource(filename)
if ret:
if getattr(ret, 'children', None):
ret = None
elif ret.is_child_of(node.ctx.bldnode):
tmp = node.ctx.srcnode.search_node(ret.path_from(node.ctx.bldnode))
if tmp and getattr(tmp, 'children', None):
ret = None
cache[key] = ret
return ret
示例2: parse_lines
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import lru_cache [as 别名]
def parse_lines(self,node):
try:
cache=node.ctx.preproc_cache_lines
except AttributeError:
cache=node.ctx.preproc_cache_lines=Utils.lru_cache(1000)
try:
return cache[node]
except KeyError:
cache[node]=lines=self.filter_comments(node)
lines.append((POPFILE,''))
lines.reverse()
return lines
示例3: cached_find_resource
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import lru_cache [as 别名]
def cached_find_resource(self,node,filename):
try:
cache=node.ctx.preproc_cache_node
except AttributeError:
cache=node.ctx.preproc_cache_node=Utils.lru_cache(1000)
key=(node,filename)
try:
return cache[key]
except KeyError:
ret=node.find_resource(filename)
if ret:
if getattr(ret,'children',None):
ret=None
elif ret.is_child_of(node.ctx.bldnode):
tmp=node.ctx.srcnode.search_node(ret.path_from(node.ctx.bldnode))
if tmp and getattr(tmp,'children',None):
ret=None
cache[key]=ret
return ret