def test_in_fileset(self): incs = {'/common/src/*': '.scanignore'} excs = {'/common/src/*.so': '.scanignore'} assert not fileset.match(None, incs, excs) assert not fileset.match('', incs, excs) assert not fileset.match('/', incs, excs) assert fileset.match('/common/src/', incs, excs) assert not fileset.match('/common/bin/', incs, excs)
def test_in_fileset(self): incs = {'/common/src/*': '.scanignore'} excs = {'/common/src/*.so':'.scanignore'} assert not fileset.match(None, incs, excs) assert not fileset.match('', incs, excs) assert not fileset.match('/', incs, excs) assert fileset.match('/common/src/', incs, excs) assert not fileset.match('/common/bin/', incs, excs)
def test_match_sources(self): incs = {'/home/elf/elf-0.5/*': '.scanignore'} excs = { '/home/elf/elf-0.5/src/elf': '.scanignore', '/home/elf/elf-0.5/src/elf.o': '.scanignore' } assert not fileset.match('/home/elf/elf-0.5/src/elf', incs, excs)
def test_default_ignore_does_not_skip_one_char_names(self): # use fileset directly to work on strings not locations from commoncode import fileset tests = [c for c in 'HFS+ Private Data'] + 'HFS+ Private Data'.split() for test in tests: assert False == fileset.match(test, includes=ignore.default_ignores, excludes={})
def is_ignored(location, ignores, unignores, skip_special=True): """ Return a tuple of (pattern , message) if a file at location is ignored or False otherwise. `ignores` and `unignores` are mappings of patterns to a reason. """ if skip_special and filetype.is_special(location): return True return fileset.match(location, includes=ignores, excludes=unignores)
def is_ignored(location, ignores): """ Return a tuple of (pattern , message) if a file at location is ignored or False otherwise. `ignores` is a mappings of patterns to a reason. Taken from scancode/plugin_ignore.py """ from commoncode.fileset import match return match(location, includes=ignores, excludes={})
def test_in_fileset_2(self): incs = {'src*': '.scanignore'} excs = {'src/ab': '.scanignore'} assert not fileset.match(None, incs, excs) assert not fileset.match('', incs, excs) assert not fileset.match('/', incs, excs) assert fileset.match('/common/src/', incs, excs) assert not fileset.match('src/ab', incs, excs) assert fileset.match('src/abbab', incs, excs)
def test_match_dot_svn_with_excludes(self): incs = {'*/.svn/*': '.scanignore'} excs = {'*/.git/*': '.scanignore'} assert fileset.match('home/common/tools/elf/.svn/', incs, excs) assert fileset.match('home/common/tools/.svn/this', incs, excs) assert not fileset.match('home/common/.git/this', incs, excs)
def test_match_empty_exclusions(self): incs = {'/src/*': '.scanignore'} excs = {'': '.scanignore'} assert fileset.match('/src/dist/build/mylib.so', incs, excs)
def test_match_exclusions_2(self): incs = {'src': '.scanignore'} excs = {'src/*.so': '.scanignore'} assert fileset.match('/some/src/this/that', incs, excs) assert not fileset.match('/src/dist/build/mylib.so', incs, excs)
def test_match_exclusions_2(self): incs = {'src': '.scanignore'} excs = {'src/*.so':'.scanignore'} assert fileset.match('/some/src/this/that', incs, excs) assert not fileset.match('/src/dist/build/mylib.so', incs, excs)
def test_match_basic(self): assert not fileset.match('/common/src/', {}, {}) assert not fileset.match('/common/src/', None, None) assert not fileset.match(None, None, None)
def is_ignored(location, ignores): """ Return a tuple of (pattern , message) if a file at location is ignored or False otherwise. `ignores` is a mappings of patterns to a reason. """ return match(location, includes=ignores, excludes={})
def test_match_sources(self): incs = {'/home/elf/elf-0.5/*': '.scanignore'} excs = {'/home/elf/elf-0.5/src/elf': '.scanignore', '/home/elf/elf-0.5/src/elf.o': '.scanignore'} assert not fileset.match('/home/elf/elf-0.5/src/elf', incs, excs)