From 581ce37bc844409b3df8287e9f9c181a274cac1b Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 13 Oct 2018 14:48:01 +0100 Subject: [PATCH] [Minor] Another try to fix bloody python --- test/functional/util/merge_coveralls.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/functional/util/merge_coveralls.py b/test/functional/util/merge_coveralls.py index 06c8ef02b..291eb2ffa 100755 --- a/test/functional/util/merge_coveralls.py +++ b/test/functional/util/merge_coveralls.py @@ -6,6 +6,7 @@ import argparse import json import os import sys +import codecs import requests @@ -46,7 +47,7 @@ parser.add_argument('--token', type=str, help='If present, the file will be uplo def merge_coverage_vectors(c1, c2): assert(len(c1) == len(c2)) - for i in xrange(0, len(c1)): + for i in range(0, len(c1)): if c1[i] is None and c2[i] is None: pass elif type(c1[i]) is int and c2[i] is None: @@ -94,7 +95,7 @@ def merge(files, j1): return files def prepare_path_mapping(): - for i in xrange(0, len(path_mapping)): + for i in range(0, len(path_mapping)): new_key = path_mapping[i][0].replace("${install-dir}", install_dir) new_key = new_key.replace("${project-root}", repository_root) new_key = new_key.replace("${build-dir}", build_dir) @@ -110,11 +111,14 @@ if __name__ == '__main__': prepare_path_mapping() - j1 = json.loads(args.input[0].read().decode("utf-8-sig")) + with codecs.open(args.input[0], 'r', 'utf-8-sig') as fh: + j1 = json.load(fh) files = merge({}, j1) - for i in xrange(1, len(args.input)): - j2 = json.loads(args.input[i].read()) + for i in range(1, len(args.input)): + with codecs.open(args.input[i], 'r', 'utf-8-sig') as fh: + j2 = json.load(fh) + files = merge(files, j2) if 'git' not in j1 and 'git' in j2: -- 2.39.5