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 3 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
8 changes: 4 additions & 4 deletions scripts/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@
except ImportError:
ez = {}
if USE_DISTRIBUTE:
exec urllib2.urlopen('http://python-distribute.org/distribute_setup.py'
).read() in ez
exec(urllib2.urlopen('http://python-distribute.org/distribute_setup.py'
Copy link
Author

Choose a reason for hiding this comment

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

These fixes were added automatically by the futurize command. The script still isn't quite python 3 compatible, but seems to be broken anyway, since the link 404s.

Copy link
Owner

Choose a reason for hiding this comment

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

Has upstream bootstrap been updated for python 3 as well?

Copy link
Author

Choose a reason for hiding this comment

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

It seems to have been updated, yes: https://raw.githubusercontent.com/buildout/buildout/master/bootstrap/bootstrap.py I don't understand the build scripts well enough to test them, so I've reverted my changes to the scripts directory in 27ce639.

My primary purpose in this PR was get the test suite to pass on Python 3 and update the trove classifiers so that pathtools no longer appears as "not ready" on the wall of python 3 readiness. The build scripts can stay on python 2 until its end of life.

).read(), ez)
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0, no_fake=True)
else:
exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
).read() in ez
exec(urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
).read(), ez)
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)

if to_reload:
Expand Down
2 changes: 1 addition & 1 deletion scripts/nosy.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def walk(_path):
try:
return next(os.walk(_path))
except NameError:
return os.walk(_path).next()
return next(os.walk(_path))
for root, directories, filenames in walk(pathname):
yield root
for directory in directories:
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