Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
40aabe3f
Commit
40aabe3f
authored
Sep 16, 2018
by
Jason R. Coombs
Committed by
GitHub
Sep 16, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1479 from jdufresne/bytes
Remove compatibility shim for bytes type
parents
318d6b02
4f165ed9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
10 deletions
+43
-10
changelog.d/1479.misc.rst
changelog.d/1479.misc.rst
+1
-0
setuptools/glob.py
setuptools/glob.py
+6
-8
setuptools/tests/files.py
setuptools/tests/files.py
+1
-2
setuptools/tests/test_glob.py
setuptools/tests/test_glob.py
+35
-0
No files found.
changelog.d/1479.misc.rst
0 → 100644
View file @
40aabe3f
Remove internal use of six.binary_type
setuptools/glob.py
View file @
40aabe3f
...
...
@@ -3,14 +3,12 @@ Filename globbing utility. Mostly a copy of `glob` from Python 3.5.
Changes include:
* `yield from` and PEP3102 `*` removed.
* `bytes` changed to `six.binary_type`.
* Hidden files are not ignored.
"""
import
os
import
re
import
fnmatch
from
setuptools.extern.six
import
binary_type
__all__
=
[
"glob"
,
"iglob"
,
"escape"
]
...
...
@@ -92,7 +90,7 @@ def _iglob(pathname, recursive):
def
glob1
(
dirname
,
pattern
):
if
not
dirname
:
if
isinstance
(
pattern
,
b
inary_type
):
if
isinstance
(
pattern
,
b
ytes
):
dirname
=
os
.
curdir
.
encode
(
'ASCII'
)
else
:
dirname
=
os
.
curdir
...
...
@@ -129,8 +127,8 @@ def glob2(dirname, pattern):
# Recursively yields relative pathnames inside a literal directory.
def
_rlistdir
(
dirname
):
if
not
dirname
:
if
isinstance
(
dirname
,
b
inary_type
):
dirname
=
binary_type
(
os
.
curdir
,
'ASCII'
)
if
isinstance
(
dirname
,
b
ytes
):
dirname
=
os
.
curdir
.
encode
(
'ASCII'
)
else
:
dirname
=
os
.
curdir
try
:
...
...
@@ -149,7 +147,7 @@ magic_check_bytes = re.compile(b'([*?[])')
def
has_magic
(
s
):
if
isinstance
(
s
,
b
inary_type
):
if
isinstance
(
s
,
b
ytes
):
match
=
magic_check_bytes
.
search
(
s
)
else
:
match
=
magic_check
.
search
(
s
)
...
...
@@ -157,7 +155,7 @@ def has_magic(s):
def
_isrecursive
(
pattern
):
if
isinstance
(
pattern
,
b
inary_type
):
if
isinstance
(
pattern
,
b
ytes
):
return
pattern
==
b'**'
else
:
return
pattern
==
'**'
...
...
@@ -169,7 +167,7 @@ def escape(pathname):
# Escaping is done by wrapping any of "*?[" between square brackets.
# Metacharacters do not work in the drive part and shouldn't be escaped.
drive
,
pathname
=
os
.
path
.
splitdrive
(
pathname
)
if
isinstance
(
pathname
,
b
inary_type
):
if
isinstance
(
pathname
,
b
ytes
):
pathname
=
magic_check_bytes
.
sub
(
br'[\1]'
,
pathname
)
else
:
pathname
=
magic_check
.
sub
(
r'[\1]'
,
pathname
)
...
...
setuptools/tests/files.py
View file @
40aabe3f
import
os
from
setuptools.extern.six
import
binary_type
import
pkg_resources.py31compat
...
...
@@ -31,7 +30,7 @@ def build_files(file_defs, prefix=""):
pkg_resources
.
py31compat
.
makedirs
(
full_name
,
exist_ok
=
True
)
build_files
(
contents
,
prefix
=
full_name
)
else
:
if
isinstance
(
contents
,
b
inary_type
):
if
isinstance
(
contents
,
b
ytes
):
with
open
(
full_name
,
'wb'
)
as
f
:
f
.
write
(
contents
)
else
:
...
...
setuptools/tests/test_glob.py
0 → 100644
View file @
40aabe3f
import
pytest
from
setuptools.glob
import
glob
from
.files
import
build_files
@
pytest
.
mark
.
parametrize
(
'tree, pattern, matches'
,
(
(
''
,
b''
,
[]),
(
''
,
''
,
[]),
(
'''
appveyor.yml
CHANGES.rst
LICENSE
MANIFEST.in
pyproject.toml
README.rst
setup.cfg
setup.py
'''
,
'*.rst'
,
(
'CHANGES.rst'
,
'README.rst'
)),
(
'''
appveyor.yml
CHANGES.rst
LICENSE
MANIFEST.in
pyproject.toml
README.rst
setup.cfg
setup.py
'''
,
b'*.rst'
,
(
b'CHANGES.rst'
,
b'README.rst'
)),
))
def
test_glob
(
monkeypatch
,
tmpdir
,
tree
,
pattern
,
matches
):
monkeypatch
.
chdir
(
tmpdir
)
build_files
({
name
:
''
for
name
in
tree
.
split
()})
assert
list
(
sorted
(
glob
(
pattern
)))
==
list
(
sorted
(
matches
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment