Skip to content

Commit

Permalink
Rely on more_itertools for unique_everseen for Python 2 compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Aug 24, 2019
1 parent 7fb8283 commit b9e783f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
5 changes: 4 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
v0.5.3
v0.6.0
======

#12: When adding implicit dirs, ensure that ancestral directories
are added and that duplicates are excluded.

The library now relies on
`more_itertools <https://pypi.org/project/more_itertools>`_.

v0.5.2
======

Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ packages = find:
include_package_data = true
python_requires = >=2.7
install_requires =
more_itertools

This comment has been minimized.

Copy link
@njohner

njohner Dec 6, 2019

I think this change breaks python 2 compatibility. Since version 6.0 more_itertools is only python 3 compatible (more-itertools/more-itertools@b18c717#diff-2eeaed663bd0d25b7e608891384b7298).

This comment has been minimized.

Copy link
@njohner

njohner Dec 10, 2019

Sorry, apparently this is fine with newer versions of PIP, see #13 and #14.
Sorry for the comment above, I answer it here so maybe the next person to stumble on this will not leave a comment or open an issue in this repo.

setup_requires = setuptools_scm >= 1.15.0

[options.extras_require]
Expand Down
22 changes: 3 additions & 19 deletions zipp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,9 @@
import functools
import itertools

__metaclass__ = type

import more_itertools

def _unique_everseen(iterable, key=None):
"List unique elements, preserving order. Remember all elements ever seen."
# unique_everseen('AAAABBBCCDAABBB') --> A B C D
# unique_everseen('ABBCcAD', str.lower) --> A B C D
seen = set()
seen_add = seen.add
if key is None:
for element in itertools.filterfalse(seen.__contains__, iterable):
seen_add(element)
yield element
else:
for element in iterable:
k = key(element)
if k not in seen:
seen_add(k)
yield element
__metaclass__ = type


def _parents(path):
Expand Down Expand Up @@ -211,7 +195,7 @@ def joinpath(self, add):

@staticmethod
def _implied_dirs(names):
return _unique_everseen(
return more_itertools.unique_everseen(
parent + "/"
for name in names
for parent in _parents(name)
Expand Down

0 comments on commit b9e783f

Please sign in to comment.