Add options and refactoring
diff --git a/coverage-tool/coverage-reporting/generate_info_file.py b/coverage-tool/coverage-reporting/generate_info_file.py
index 0c0f39a..a606682 100755
--- a/coverage-tool/coverage-reporting/generate_info_file.py
+++ b/coverage-tool/coverage-reporting/generate_info_file.py
@@ -340,7 +340,7 @@
# regex: find all the lines starting with 'if' or 'else if'
# (possibly preceded by whitespaces/tabs)
pattern = re.compile(r"^\s+if|^\s+} else if|^\s+else if")
- for i, line in enumerate(open(abs_path_file)):
+ for i, line in enumerate(open(abs_path_file, encoding='utf-8')):
for match in re.finditer(pattern, line):
branching_lines.append(i + 1)
while branching_lines:
@@ -355,7 +355,7 @@
# regex: find all the lines starting with 'switch'
# (possibly preceded by whitespaces/tabs)
pattern = re.compile(r"^\s+switch")
- for i, line in enumerate(open(abs_path_file)):
+ for i, line in enumerate(open(abs_path_file, encoding='utf-8')):
for match in re.finditer(pattern, line):
switch_lines.append(i + 1)
while switch_lines:
@@ -380,7 +380,7 @@
help='Output info file name',
default="coverage.info")
args = parser.parse_args()
-with open(args.json) as json_file:
+with open(args.json, encoding='utf-8') as json_file:
json_data = json.load(json_file)
info_file = open(args.info, "w+")
error_log = open("error_log.txt", "w+")
@@ -390,7 +390,7 @@
abs_path_file = os.path.join(args.workspace, relative_path)
if not os.path.exists(abs_path_file):
continue
- source = open(abs_path_file)
+ source = open(abs_path_file, encoding='utf-8')
lines = source.readlines()
info_file.write('TN:\n')
info_file.write('SF:' + os.path.abspath(abs_path_file) + '\n')