Skip to content

Commit

Permalink
Migrate benchmark_json_merge in webkitpy/benchmark_runner to Python 3
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=260307

Reviewed by Dewei Zhu.

Imports reduce from functools since it is no longer a built-in function in Python 3.
Uses Python 3 list comprehension syntax to add the object keys.

* Tools/Scripts/webkitpy/benchmark_runner/benchmark_json_merge.py:
(deepAppend):

Canonical link: https://commits.webkit.org/267216@main
  • Loading branch information
jcarterbohan authored and xw committed Aug 24, 2023
1 parent baa5c67 commit 1238f66
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from functools import reduce


def deepAppend(value1, value2, currentKey=None):
if type(value1) != type(value2):
Expand All @@ -32,7 +34,7 @@ def deepAppend(value1, value2, currentKey=None):
return value1 + value2

result = {}
for key in (value1.keys() + value2.keys()):
for key in [*value1.keys(), *value2.keys()]:
if key not in result:
result[key] = deepAppend(value1[key], value2[key], key)
return result
Expand Down

0 comments on commit 1238f66

Please sign in to comment.