Пример #1
0
 def test_forward_slashes(self):
     """tests that multiple foward slashes are collapsed to single forward
     slashes and trailing forward slashes are removed"""
     self.assertEqual(u'/', normalize_pattern(u'/'))
     self.assertEqual(u'/', normalize_pattern(u'//'))
     self.assertEqual(u'/foo/bar', normalize_pattern(u'/foo/bar'))
     self.assertEqual(u'foo/bar', normalize_pattern(u'foo/bar/'))
     self.assertEqual(u'/foo/bar', normalize_pattern(u'//foo//bar//'))
Пример #2
0
 def test_forward_slashes(self):
     """tests that multiple foward slashes are collapsed to single forward
     slashes and trailing forward slashes are removed"""
     self.assertEqual(u'/', normalize_pattern(u'/'))
     self.assertEqual(u'/', normalize_pattern(u'//'))
     self.assertEqual(u'/foo/bar', normalize_pattern(u'/foo/bar'))
     self.assertEqual(u'foo/bar', normalize_pattern(u'foo/bar/'))
     self.assertEqual(u'/foo/bar', normalize_pattern(u'//foo//bar//'))
Пример #3
0
 def test_backslashes(self):
     """tests that backslashes are converted to forward slashes, multiple
     backslashes are collapsed to single forward slashes and trailing
     backslashes are removed"""
     self.assertEqual(u'/', normalize_pattern(u'\\'))
     self.assertEqual(u'/', normalize_pattern(u'\\\\'))
     self.assertEqual(u'/foo/bar', normalize_pattern(u'\\foo\\bar'))
     self.assertEqual(u'foo/bar', normalize_pattern(u'foo\\bar\\'))
     self.assertEqual(u'/foo/bar', normalize_pattern(u'\\\\foo\\\\bar\\\\'))
Пример #4
0
 def test_backslashes(self):
     """tests that backslashes are converted to forward slashes, multiple
     backslashes are collapsed to single forward slashes and trailing
     backslashes are removed"""
     self.assertEqual(u'/', normalize_pattern(u'\\'))
     self.assertEqual(u'/', normalize_pattern(u'\\\\'))
     self.assertEqual(u'/foo/bar', normalize_pattern(u'\\foo\\bar'))
     self.assertEqual(u'foo/bar', normalize_pattern(u'foo\\bar\\'))
     self.assertEqual(u'/foo/bar', normalize_pattern(u'\\\\foo\\\\bar\\\\'))
Пример #5
0
def add_unique_user_ignores(new_ignores):
    """Add entries to the user's ignore list if not present.

    :param new_ignores: A list of ignore patterns
    :return: The list of ignores that were added
    """
    ignored = get_user_ignores()
    to_add = []
    for ignore in new_ignores:
        ignore = globbing.normalize_pattern(ignore)
        if ignore not in ignored:
            ignored.add(ignore)
            to_add.append(ignore)

    if not to_add:
        return []

    f = open(config.user_ignore_config_filename(), 'ab')
    try:
        for pattern in to_add:
            f.write(pattern.encode('utf8') + '\n')
    finally:
        f.close()

    return to_add
Пример #6
0
def parse_ignore_file(f):
    """Read in all of the lines in the file and turn it into an ignore list"""
    ignored = set()
    for line in f.read().decode('utf8').split('\n'):
        line = line.rstrip('\r\n')
        if not line or line.startswith('#'):
            continue
        ignored.add(globbing.normalize_pattern(line))
    return ignored
Пример #7
0
 def test_mixed_slashes(self):
     """tests that multiple mixed slashes are collapsed to single forward
     slashes and trailing mixed slashes are removed"""
     self.assertEqual(u'/foo/bar', normalize_pattern(u'\\/\\foo//\\///bar/\\\\/'))
Пример #8
0
 def test_mixed_slashes(self):
     """tests that multiple mixed slashes are collapsed to single forward
     slashes and trailing mixed slashes are removed"""
     self.assertEqual(u'/foo/bar',
                      normalize_pattern(u'\\/\\foo//\\///bar/\\\\/'))