forked from cpburnz/python-pathspec
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
120 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
# coding: utf-8 | ||
# encoding: utf-8 | ||
""" | ||
This module provides compatibility between Python 2 and 3. Hardly | ||
anything is used by this project to constitute including `six`_. | ||
.. _`six`: http://pythonhosted.org/six | ||
""" | ||
|
||
try: | ||
import sys | ||
|
||
if sys.version_info[0] < 3: | ||
# Python 2. | ||
string_types = (basestring,) | ||
except NameError: | ||
|
||
def viewkeys(mapping): | ||
return mapping.viewkeys() | ||
|
||
else: | ||
# Python 3. | ||
string_types = (str,) | ||
|
||
def viewkeys(mapping): | ||
return mapping.keys() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# coding: utf-8 | ||
# encoding: utf-8 | ||
""" | ||
This module provides the base definition for patterns. | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# encoding: utf-8 | ||
""" | ||
This package provides tests. | ||
""" | ||
|
||
from .test_pathspec import PathSpecTest | ||
from .test_gitignore import GitIgnoreTest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# coding: utf-8 | ||
# encoding: utf-8 | ||
""" | ||
This script tests ``GitIgnorePattern``. | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# encoding: utf-8 | ||
""" | ||
This script tests ``PathSpec``. | ||
""" | ||
|
||
import unittest | ||
|
||
import pathspec | ||
|
||
class PathSpecTest(unittest.TestCase): | ||
""" | ||
The ``PathSpecTest`` class tests the ``PathSpec`` class. | ||
""" | ||
|
||
def test_01_windows_paths(self): | ||
""" | ||
Tests that Windows paths will be properly normalized and matched. | ||
""" | ||
spec = pathspec.PathSpec.from_lines('gitignore', [ | ||
'*.txt', | ||
'!test1/', | ||
]) | ||
results = set(spec.match_files([ | ||
'src\\test1\\a.txt', | ||
'src\\test1\\b.txt', | ||
'src\\test1\\c\\c.txt', | ||
'src\\test2\\a.txt', | ||
'src\\test2\\b.txt', | ||
'src\\test2\\c\\c.txt', | ||
], separators=('\\',))) | ||
self.assertEquals(results, { | ||
'src\\test2\\a.txt', | ||
'src\\test2\\b.txt', | ||
'src\\test2\\c\\c.txt', | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters