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
b8327d7f
Commit
b8327d7f
authored
May 24, 2013
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unique_everseen from Python 2.7 docs
--HG-- branch : distribute
parent
4a45583a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
setuptools/package_index.py
setuptools/package_index.py
+19
-0
No files found.
setuptools/package_index.py
View file @
b8327d7f
"""PyPI and direct package downloading"""
import
sys
,
os
.
path
,
re
,
urlparse
,
urllib
,
urllib2
,
shutil
,
random
,
socket
,
cStringIO
import
itertools
import
base64
import
httplib
from
pkg_resources
import
*
...
...
@@ -134,6 +135,24 @@ def interpret_distro_name(location, basename, metadata,
platform
=
platform
)
# From Python 2.7 docs
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
.
ifilterfalse
(
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
REL
=
re
.
compile
(
"""<([^>]*
\
s
r
el
\
s*=
\
s*['"]?([^'">]+)[^>]*)>"""
,
re
.
I
)
# this line is here to fix emacs' cruddy broken syntax highlighting
...
...
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