iglob.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:vsi_common 作者: VisionSystemsInc 项目源码 文件源码
def fnmatch_filter(names, pat, casesensitive):
  """Return the subset of the list NAMES that match PAT"""
  result=[]

  if casesensitive:
    if not pat in _casecache:
      res = translate(pat)
      if len(_casecache) >= _MAXCACHE:
        _casecache.clear()
      _casecache[pat] = re.compile(res)
    match=_casecache[pat].match

    for name in names:
      if match(name):
        result.append(name)
  else:
    if not pat in _nocasecache:
      res = translate(pat)
      if len(_nocasecache) >= _MAXCACHE:
        _nocasecache.clear()
      _nocasecache[pat] = re.compile(res, re.IGNORECASE)
    match=_nocasecache[pat].match

    pat=ntpath.normcase(pat)
    for name in names:
      if match(ntpath.normcase(name)):
        result.append(name)
  return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号