Example #1
0
 def test_match(self):
     t1 = translate("*.{icns,ico,jpg,jpeg,m4v,nib,pdf,png,psd,pyc,rtf,tif,tiff,xib}")
     p1 = re.compile(t1)
     t2 = translate("/System/Library/Frameworks/**/Headers/**/*")
     p2 = re.compile(t2)
     print(p1.search("/path/to/icon/myicon.jpg"))
     print(p2.search("/System/Library/Frameworks/hola/Headers/uno/dos.h"))
     self.assertTrue(fnmatch("", ""))
     self.assertTrue(fnmatch("/path/to/icon/myicon.ico", "*.{icns,ico,jpg,jpeg,m4v,nib,pdf,png,psd,pyc,rtf,tif,tiff,xib}"))
     self.assertTrue(fnmatch("", ""))
Example #2
0
 def pathInBrowser(self, path):
     key = os.path.isdir(path) and "directories" or "files"
     excludes = [ pat for pat in 
         [ getattr(self, exclude) for exclude in self.BROWSER['excludes'][key] ]
         if pat is not None
     ]
     if any((fnmatch.fnmatch(path, pat) for pat in excludes)):
         return False
     includes = [ pat for pat in 
         [ getattr(self, include) for include in self.BROWSER['includes'][key] ]
         if pat is not None
     ]
     if any((fnmatch.fnmatch(path, pat) for pat in includes)):
         return True
     return True
Example #3
0
 def filterAcceptsRow(self, sourceRow, sourceParent):
     sIndex = self.sourceModel().index(sourceRow, 0, sourceParent)
     node = self.sourceModel().node(sIndex)
     
     if isinstance(node, ProjectTreeNode): return True
     regexp = self.filterRegExp()
     if not regexp.isEmpty():
         pattern = regexp.pattern()
         return fnmatch.fnmatch(node.path(), pattern)
     return True
Example #4
0
 def buildSettings(self, path, context):
     settings = []
     for s in self.settings:
         rank = []
         if s.name == "DEFAULT" and s.config.source.exists():
             settings.append((0, s))
         elif s.pattern and fnmatch.fnmatch(path, s.pattern):
             settings.append((1, s))
         elif s.selector and s.selector.does_match(context, rank):
             settings.append((rank.pop(), s))
     settings.sort(key=lambda t: t[0], reverse=True)
     #print([(s[0], s[1].name, s[1].config.source.name) for s in settings])
     return ContextSettings([s[1] for s in settings])