Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f30b5ae6
Commit
f30b5ae6
authored
Sep 18, 2011
by
Éric Araujo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace cmp function with key function
parent
cc06ad18
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
15 deletions
+2
-15
Lib/packaging/create.py
Lib/packaging/create.py
+2
-15
No files found.
Lib/packaging/create.py
View file @
f30b5ae6
...
...
@@ -28,7 +28,6 @@ import sysconfig
import
tokenize
from
hashlib
import
md5
from
textwrap
import
dedent
from
functools
import
cmp_to_key
from
configparser
import
RawConfigParser
# importing this with an underscore as it should be replaced by the
# dict form or another structures for all purposes
...
...
@@ -370,21 +369,9 @@ class MainProgram:
dist
.
data_files
=
[(
''
,
dist
.
data_files
)]
# add tokens in the destination paths
vars
=
{
'distribution.name'
:
data
[
'name'
]}
path_tokens
=
list
(
sysconfig
.
get_paths
(
vars
=
vars
).
items
())
# TODO replace this with a key function
def
length_comparison
(
x
,
y
):
len_x
=
len
(
x
[
1
])
len_y
=
len
(
y
[
1
])
if
len_x
==
len_y
:
return
0
elif
len_x
<
len_y
:
return
-
1
else
:
return
1
path_tokens
=
sysconfig
.
get_paths
(
vars
=
vars
).
items
()
# sort tokens to use the longest one first
path_tokens
.
sort
(
key
=
cmp_to_key
(
length_comparison
))
path_tokens
=
sorted
(
path_tokens
,
key
=
lambda
x
:
len
(
x
[
1
]
))
for
dest
,
srcs
in
(
dist
.
data_files
or
[]):
dest
=
os
.
path
.
join
(
sys
.
prefix
,
dest
)
dest
=
dest
.
replace
(
os
.
path
.
sep
,
'/'
)
...
...
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