Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 compatibility #7

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ MANIFEST
.coverage
.pythoscope/
htmlcov/
.tox
5 changes: 5 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ pathtools

Pattern matching and various utilities for file systems paths.

Tests
=====
To run the test suite, run the following in the project directory:

pip install tox
tox
2 changes: 1 addition & 1 deletion pathtools/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def walk(path, topdown=topdown, followlinks=followlinks):
try:
yield next(os.walk(path, topdown=topdown, followlinks=followlinks))
except NameError:
yield os.walk(path, topdown=topdown, followlinks=followlinks).next() #IGNORE:E1101
yield next(os.walk(path, topdown=topdown, followlinks=followlinks)) #IGNORE:E1101
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is now exactly the same line as inside the "try". I think this was here for Python 2.6 compatibility. Instead of this change, the except clause should simply be removed.

return walk


Expand Down
6 changes: 3 additions & 3 deletions pathtools/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def _match_path(pathname,
>>> _match_path("/users/gorakhargosh/FOOBAR.PY", ["*.py"], ["*.PY"], False)
Traceback (most recent call last):
...
ValueError: conflicting patterns `set(['*.py'])` included and excluded
ValueError: conflicting patterns `['*.py']` included and excluded
"""
if not case_sensitive:
included_patterns = set(map(_string_lower, included_patterns))
Expand All @@ -122,7 +122,7 @@ def _match_path(pathname,
common_patterns = included_patterns & excluded_patterns
if common_patterns:
raise ValueError('conflicting patterns `%s` included and excluded'\
% common_patterns)
% list(common_patterns))
return (match_path_against(pathname, included_patterns, case_sensitive)\
and not match_path_against(pathname, excluded_patterns,
case_sensitive))
Expand Down Expand Up @@ -167,7 +167,7 @@ def match_path(pathname,
>>> match_path("/users/gorakhargosh/FOOBAR.PY", ["*.py"], ["*.PY"], False)
Traceback (most recent call last):
...
ValueError: conflicting patterns `set(['*.py'])` included and excluded
ValueError: conflicting patterns `['*.py']` included and excluded
"""
included = ["*"] if included_patterns is None else included_patterns
excluded = [] if excluded_patterns is None else excluded_patterns
Expand Down
4 changes: 2 additions & 2 deletions pathtools/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
# When updating this version number, please update the
# ``docs/source/global.rst.inc`` file as well.
VERSION_MAJOR = 0
VERSION_MINOR = 1
VERSION_BUILD = 1
VERSION_MINOR = 2
VERSION_BUILD = 0
VERSION_INFO = (VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD)
VERSION_STRING = "%d.%d.%d" % VERSION_INFO

Expand Down
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ def read_file(filename):
'Topic :: Software Development :: Libraries',
'Topic :: System :: Filesystems',
'Topic :: Utilities',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
],
packages=['pathtools']
)
9 changes: 9 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[tox]
envlist = py27,py35

[testenv]
usedevelop = True
commands =
python {toxinidir}/tests/run_tests.py
deps =
nose