Example #1
0
    def test_is_ignored_real_location_skip_special(self):
        test_file_location = self.get_test_loc('ignore/vcs.tgz')
        assert not ignore.is_ignored(test_file_location, {'asdf': 'skip'}, {}, skip_special=True)
        assert not ignore.is_ignored(test_file_location, {'asdf': 'skip'}, {}, skip_special=False)

        assert not ignore.is_ignored(test_file_location, {'asdf': 'skip'}, {}, skip_special=True)
        assert not ignore.is_ignored(test_file_location, {'asdf': 'skip'}, {}, skip_special=False)
Example #2
0
    def test_is_ignored_special_files_skip_special(self):
        test_fifo = self.get_temp_file()
        os.mkfifo(test_fifo)
        assert ignore.is_ignored(test_fifo, {'asdf': 'skip'}, {}, skip_special=True)
        assert not ignore.is_ignored(test_fifo, {'asdf': 'skip'}, {}, skip_special=False)

        test_symlink = self.get_temp_file()
        test_file_location = self.get_test_loc('ignore/vcs.tgz')
        os.symlink(test_file_location, test_symlink)
        assert ignore.is_ignored(test_symlink, {'asdf': 'skip'}, {}, skip_special=True)
        assert not ignore.is_ignored(test_symlink, {'asdf': 'skip'}, {}, skip_special=False)
    def check_default(self, test_dir, expected_message):
        for top, dirs, files in os.walk(test_dir, topdown=True):
            not_ignored = []
            for d in dirs:
                p = os.path.join(top, d)
                ign = ignore.is_ignored(p, ignore.default_ignores, {})
                if not ign:
                    not_ignored.append(d)
            dirs[:] = not_ignored

            for f in files:
                p = os.path.join(top, f)
                ign = ignore.is_ignored(p, ignore.default_ignores, {})
                if ign:
                    assert ign == expected_message
Example #4
0
    def check_default(self, test_dir, expected_message):
        for top, dirs, files in os.walk(test_dir, topdown=True):
            not_ignored = []
            for d in dirs:
                p = os.path.join(top, d)
                ign = ignore.is_ignored(p, ignore.default_ignores, {})
                if not ign:
                    not_ignored.append(d)
            dirs[:] = not_ignored

            for f in files:
                p = os.path.join(top, f)
                ign = ignore.is_ignored(p, ignore.default_ignores, {})
                if ign:
                    assert ign == expected_message
    def test_default_ignores_mac1(self):
        test_dir = self.extract_test_tar('ignore/excludes/mac.tgz')
        test_base = os.path.join(test_dir, 'mac')

        test = os.path.join(test_base, '__MACOSX')
        result = ignore.is_ignored(test, ignore.default_ignores, {})
        assert 'Default ignore: MacOSX artifact' == result
    def test_is_ignored_default_ignores_mac2(self):
        test_dir = self.extract_test_tar('ignore/excludes/mac.tgz')
        test_base = os.path.join(test_dir, 'mac')

        test = os.path.join(test_base, '__MACOSX/comp_match/smallrepo/._jetty_1.0_index.csv')
        result = ignore.is_ignored(test, ignore.default_ignores, {})
        assert 'Default ignore: MacOSX artifact' == result
    def test_default_ignores_mac2(self):
        test_dir = self.extract_test_tar('ignore/excludes/mac.tgz')
        test_base = os.path.join(test_dir, 'mac')

        test = os.path.join(test_base, '__MACOSX/comp_match/smallrepo/._jetty_1.0_index.csv')
        result = ignore.is_ignored(test, ignore.default_ignores, {})
        assert 'Default ignore: MacOSX artifact' == result
    def test_default_ignores_eclipse4(self):
        test_dir = self.extract_test_tar('ignore/excludes/eclipse.tgz')
        test_base  = os.path.join(test_dir, 'eclipse')

        test = os.path.join(test_base, '.pydevproject')
        result = ignore.is_ignored(test, ignore.default_ignores, {})
        assert 'Default ignore: Eclipse IDE artifact' == result
Example #9
0
 def test_ignore_glob_file(self):
     test = (
         'common/src/test/sample.txt',
         {'*.txt': 'test ignore'},
         {}
     )
     assert is_ignored(*test)
Example #10
0
 def test_ignore_single_path(self):
     test = (
         'common/src/test/sample.txt',
         {'src/test/sample.txt': 'test ignore'},
         {}
     )
     assert is_ignored(*test)
 def test_ignore_single_path(self):
     test = (
         'common/src/test/sample.txt',
         {'src/test/sample.txt': 'test ignore'},
         {}
     )
     assert is_ignored(*test)
Example #12
0
    def test_default_ignores_eclipse4(self):
        test_dir = self.extract_test_tar('ignore/excludes/eclipse.tgz')
        test_base = os.path.join(test_dir, 'eclipse')

        test = os.path.join(test_base, '.pydevproject')
        result = ignore.is_ignored(test, ignore.default_ignores, {})
        assert 'Default ignore: Eclipse IDE artifact' == result
Example #13
0
    def test_default_ignores_mac1(self):
        test_dir = self.extract_test_tar('ignore/excludes/mac.tgz')
        test_base = os.path.join(test_dir, 'mac')

        test = os.path.join(test_base, '__MACOSX')
        result = ignore.is_ignored(test, ignore.default_ignores, {})
        assert 'Default ignore: MacOSX artifact' == result
 def test_ignore_glob_file(self):
     test = (
         'common/src/test/sample.txt',
         {'*.txt': 'test ignore'},
         {}
     )
     assert is_ignored(*test)
Example #15
0
    def test_skip_vcs_files_and_dirs(self):
        test_dir = self.extract_test_tar('ignore/vcs.tgz')
        result = []
        for top, dirs, files in os.walk(test_dir, topdown=True):
            not_ignored = []
            for d in dirs:
                p = os.path.join(top, d)
                ign = ignore.is_ignored(p, ignore.default_ignores, {})
                tp = fileutils.as_posixpath(p.replace(test_dir, ''))
                result.append((
                    tp,
                    ign,
                ))
                if not ign:
                    not_ignored.append(d)

            # skip ignored things
            dirs[:] = not_ignored

            for f in files:
                p = os.path.join(top, f)
                ign = ignore.is_ignored(p, ignore.default_ignores, {})
                tp = fileutils.as_posixpath(p.replace(test_dir, ''))
                result.append((
                    tp,
                    ign,
                ))

        expected = [
            ('/vcs', False),
            ('/vcs/.bzr', 'Default ignore: Bazaar artifact'),
            ('/vcs/.git', 'Default ignore: Git artifact'),
            ('/vcs/.hg', 'Default ignore: Mercurial artifact'),
            ('/vcs/.repo', 'Default ignore: Multiple Git repository artifact'),
            ('/vcs/.svn', 'Default ignore: SVN artifact'),
            ('/vcs/CVS', 'Default ignore: CVS artifact'),
            ('/vcs/_darcs', 'Default ignore: Darcs artifact'),
            ('/vcs/_MTN', 'Default ignore: Monotone artifact'),
            ('/vcs/.bzrignore', 'Default ignore: Bazaar config artifact'),
            ('/vcs/.cvsignore', 'Default ignore: CVS config artifact'),
            ('/vcs/.gitignore', 'Default ignore: Git config artifact'),
            ('/vcs/.hgignore', 'Default ignore: Mercurial config artifact'),
            ('/vcs/.svnignore', 'Default ignore: SVN config artifact'),
            ('/vcs/vssver.scc', 'Default ignore: Visual Source Safe artifact'),
        ]
        assert sorted(expected) == sorted(result)
Example #16
0
    def test_default_ignores_mac5(self):
        test_dir = self.extract_test_tar('ignore/excludes/mac.tgz')
        test_base = os.path.join(test_dir, 'mac')

        test = os.path.join(test_base, '._.DS_Store')
        result = ignore.is_ignored(test, ignore.default_ignores, {})
        # this is really weird as a behavior
        assert 'Default ignore: MacOSX artifact' == result
    def test_is_ignored_skip_vcs_files_and_dirs(self):
        test_dir = self.extract_test_tar('ignore/vcs.tgz')
        result = []
        for top, dirs, files in os.walk(test_dir, topdown=True):
            not_ignored = []
            for d in dirs:
                p = os.path.join(top, d)
                ign = ignore.is_ignored(p, ignore.default_ignores, {})
                tp = fileutils.as_posixpath(p.replace(test_dir, ''))
                result.append((
                    tp,
                    ign,
                ))
                if not ign:
                    not_ignored.append(d)

            # skip ignored things
            dirs[:] = not_ignored

            for f in files:
                p = os.path.join(top, f)
                ign = ignore.is_ignored(p, ignore.default_ignores, {})
                tp = fileutils.as_posixpath(p.replace(test_dir, ''))
                result.append((
                    tp,
                    ign,
                ))

        expected = [
            ('/vcs', False),
            ('/vcs/.bzr', True),
            ('/vcs/.git', True),
            ('/vcs/.hg', True),
            ('/vcs/.repo', True),
            ('/vcs/.svn', True),
            ('/vcs/CVS', True),
            ('/vcs/_darcs', True),
            ('/vcs/_MTN', True),
            ('/vcs/.bzrignore', True),
            ('/vcs/.cvsignore', True),
            ('/vcs/.gitignore', True),
            ('/vcs/.hgignore', True),
            ('/vcs/.svnignore', True),
            ('/vcs/vssver.scc', True),
        ]
        assert sorted(expected) == sorted(result)
    def test_default_ignores_mac5(self):
        test_dir = self.extract_test_tar('ignore/excludes/mac.tgz')
        test_base = os.path.join(test_dir, 'mac')

        test = os.path.join(test_base, '._.DS_Store')
        result = ignore.is_ignored(test, ignore.default_ignores, {})
        # this is really weird as a behavior
        assert 'Default ignore: MacOSX artifact' == result
Example #19
0
def should_extract(location, kinds, ignore_pattern=()):
    """
    Return True if this location should be extracted based on the provided
    kinds
    """
    location = os.path.abspath(os.path.expanduser(location))
    ignore_pattern = {extension : 'User ignore: Supplied by --ignore' for extension in ignore_pattern}
    should_ignore = is_ignored(location, ignore_pattern)
    if get_extractor(location, kinds) and not should_ignore:
        return True
    def test_skip_vcs_files_and_dirs(self):
        test_dir = self.extract_test_tar('ignore/vcs.tgz')
        result = []
        for top, dirs, files in os.walk(test_dir, topdown=True):
            not_ignored = []
            for d in dirs:
                p = os.path.join(top, d)
                ign = ignore.is_ignored(p, ignore.default_ignores, {})
                tp = fileutils.as_posixpath(p.replace(test_dir, ''))
                result.append((tp, ign,))
                if not ign:
                    not_ignored.append(d)

            # skip ignored things
            dirs[:] = not_ignored

            for f in files:
                p = os.path.join(top, f)
                ign = ignore.is_ignored(p, ignore.default_ignores, {})
                tp = fileutils.as_posixpath(p.replace(test_dir, ''))
                result.append((tp, ign,))

        expected = [
            ('/vcs', False),
            ('/vcs/.bzr', 'Default ignore: Bazaar artifact'),
            ('/vcs/.git', 'Default ignore: Git artifact'),
            ('/vcs/.hg', 'Default ignore: Mercurial artifact'),
            ('/vcs/.repo', 'Default ignore: Multiple Git repository artifact'),
            ('/vcs/.svn', 'Default ignore: SVN artifact'),
            ('/vcs/CVS', 'Default ignore: CVS artifact'),
            ('/vcs/_darcs', 'Default ignore: Darcs artifact'),
            ('/vcs/_MTN', 'Default ignore: Monotone artifact'),
            ('/vcs/.bzrignore', 'Default ignore: Bazaar config artifact'),
            ('/vcs/.cvsignore', 'Default ignore: CVS config artifact'),
            ('/vcs/.gitignore', 'Default ignore: Git config artifact'),
            ('/vcs/.hgignore', 'Default ignore: Mercurial config artifact'),
            ('/vcs/.svnignore', 'Default ignore: SVN config artifact'),
            ('/vcs/vssver.scc', 'Default ignore: Visual Source Safe artifact'),
        ]
        assert sorted(expected) == sorted(result)
Example #21
0
 def test_default_ignores_msft(self):
     test_dir = self.extract_test_tar('ignore/excludes/msft-vs.tgz')
     test = os.path.join(test_dir, 'msft-vs/tst.sluo')
     result = ignore.is_ignored(test, ignore.default_ignores, {})
     assert 'Default ignore: Microsoft VS project artifact' == result
Example #22
0
 def test_is_ignored_path_string_skip_special(self):
     test_path = '/test/path'
     assert ignore.is_ignored(test_path, {'asdf': 'skip'}, {}, skip_special=True)
     assert not ignore.is_ignored(test_path, {'asdf': 'skip'}, {}, skip_special=False)
Example #23
0
    def test_is_ignored_default_ignores_eclipse3(self):
        test_dir = self.extract_test_tar('ignore/excludes/eclipse.tgz')
        test_base = os.path.join(test_dir, 'eclipse')

        test = os.path.join(test_base, '.project')
        assert ignore.is_ignored(test, ignore.default_ignores, {})
Example #24
0
    def test_is_ignored_default_ignores_mac4(self):
        test_dir = self.extract_test_tar('ignore/excludes/mac.tgz')
        test_base = os.path.join(test_dir, 'mac')

        test = os.path.join(test_base, '.DS_Store/a')
        assert ignore.is_ignored(test, ignore.default_ignores, {})
 def test_default_ignores_msft(self):
     test_dir = self.extract_test_tar('ignore/excludes/msft-vs.tgz')
     test = os.path.join(test_dir, 'msft-vs/tst.sluo')
     result = ignore.is_ignored(test, ignore.default_ignores, {})
     assert 'Default ignore: Microsoft VS project artifact' == result