def filter_file(self, sf): if FileUtil.is_hidden(sf.filename) and self.settings.excludehidden: return False if sf.filetype == FileType.Archive: return self.settings.searcharchives and \ self.is_archive_search_file(sf.filename) return not self.settings.archivesonly and \ self.is_search_file(sf.filename)
def filter_file(self, sf): if FileUtil.is_hidden(sf.filename) and self.settings.excludehidden: return False if sf.filetype == FileType.Archive: return self.settings.searcharchives and self.is_archive_search_file( sf.filename) return not self.settings.archivesonly and self.is_search_file( sf.filename)
def is_search_dir(self, d): path_elems = [p for p in d.split(os.sep) if p not in FileUtil.DOT_DIRS] if self.settings.excludehidden: for p in path_elems: if FileUtil.is_hidden(p): return False if self.settings.in_dirpatterns and \ not any_matches_any_pattern(path_elems, self.settings.in_dirpatterns): return False if self.settings.out_dirpatterns and \ any_matches_any_pattern(path_elems, self.settings.out_dirpatterns): return False return True
def test_is_hidden_double_dot(self): filename = '..' self.assertFalse(FileUtil.is_hidden(filename))
def test_is_hidden_not_hidden_file(self): filename = 'filename.txt' self.assertFalse(FileUtil.is_hidden(filename))
def test_is_hidden_hidden_file(self): filename = '.filename.txt' self.assertTrue(FileUtil.is_hidden(filename))