Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xavier Thompson
slapos.buildout
Commits
52198b81
Commit
52198b81
authored
Jan 04, 2024
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fix/opti] Fix "Remove redundant deepcopies"
Also, remove more redundant deepcopies
parent
9d6659c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
24 deletions
+19
-24
src/zc/buildout/buildout.py
src/zc/buildout/buildout.py
+19
-24
No files found.
src/zc/buildout/buildout.py
View file @
52198b81
...
...
@@ -2275,35 +2275,30 @@ def _dists_sig(dists):
return
result
def
_update_section
(
s1
,
s2
):
# Base section 2 on section 1; section 1 is copied, with key-value pairs
# in section 2 overriding those in section 1. If there are += or -=
# operators in section 2, process these to add or subtract items (delimited
# by newlines) from the preexisting values.
# Sort on key, then on the addition or subtraction operator (+ comes first)
for
k
,
v
in
sorted
(
s2
.
items
(),
key
=
lambda
x
:
(
x
[
0
].
rstrip
(
' +'
),
x
[
0
][
-
1
])):
# Base section 2 on section 1; key-value pairs in s2 override those in s1.
# If there are += or -= operators in s2, process these to add or subtract
# items (delimited by newlines) from the preexisting values.
# Sort on key, then on + and - operators, so that KEY < KEY + < KEY -, to
# process them in this order if several are defined in the same section.
# Section s1 is modified in place.
keysort
=
lambda
x
:
(
x
[
0
].
rstrip
(
' +'
),
x
[
0
].
endswith
(
'+'
))
for
k
,
v
in
sorted
(
s2
.
items
(),
key
=
keysort
):
if
k
.
endswith
(
'+'
):
key
=
k
.
rstrip
(
' +'
)
implicit_value
=
SectionKey
(
""
,
"IMPLICIT_VALUE"
)
# Find v1 in s2 first; it may have been defined locally too.
section_key
=
s2
.
get
(
key
,
s1
.
get
(
key
,
implicit_value
))
section_key
=
copy
.
deepcopy
(
section_key
)
section_key
.
addToValue
(
v
.
value
,
v
.
source
)
value
=
s1
.
get
(
key
,
SectionKey
(
""
,
"IMPLICIT_VALUE"
))
value
.
addToValue
(
v
.
value
,
v
.
source
)
s1
[
key
]
=
value
elif
k
.
endswith
(
'-'
):
key
=
k
.
rstrip
(
' -'
)
implicit_value
=
SectionKey
(
""
,
"IMPLICIT_VALUE"
)
# Find v1 in s2 first; it may have been set by a += operation first
section_key
=
s2
.
get
(
key
,
s1
.
get
(
key
,
implicit_value
))
section_key
=
copy
.
deepcopy
(
section_key
)
section_key
.
removeFromValue
(
v
.
value
,
v
.
source
)
value
=
s1
.
get
(
key
,
SectionKey
(
""
,
"IMPLICIT_VALUE"
))
value
.
removeFromValue
(
v
.
value
,
v
.
source
)
s1
[
key
]
=
value
else
:
key
=
k
section_key
=
v
if
key
in
s1
:
v1
=
s1
[
key
]
v1
.
overrideValue
(
section_key
)
else
:
s1
[
key
]
=
section_key
if
k
in
s1
:
v1
=
s1
[
k
]
v1
.
overrideValue
(
v
)
else
:
s1
[
k
]
=
v
return
s1
def
_update
(
d1
,
d2
):
...
...
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