tools: don't use binary flag for opening text files

This commit is contained in:
Milanka Ringwald 2020-11-06 13:55:00 +01:00
parent 46059ae4c6
commit 3e90877db8
3 changed files with 8 additions and 8 deletions

View File

@ -37,7 +37,7 @@ def replacePlaceholder(template, title, lable):
def writeAPI(fout, infile_name): def writeAPI(fout, infile_name):
global code_identation global code_identation
state = State.SearchStartAPI state = State.SearchStartAPI
with open(infile_name, 'rb') as fin: with open(infile_name, 'r') as fin:
for line in fin: for line in fin:
if state == State.SearchStartAPI: if state == State.SearchStartAPI:
parts = re.match('\s*(/\*).*API_START.*(\*/)',line) parts = re.match('\s*(/\*).*API_START.*(\*/)',line)

View File

@ -111,7 +111,7 @@ def processTextLine(line, ref_prefix):
def getExampleTitle(example_path): def getExampleTitle(example_path):
example_title = '' example_title = ''
with open(example_path, 'rb') as fin: with open(example_path, 'r') as fin:
for line in fin: for line in fin:
parts = re.match('.*(EXAMPLE_START)\((.*)\):\s*(.*)(\*/)?\n',line) parts = re.match('.*(EXAMPLE_START)\((.*)\):\s*(.*)(\*/)?\n',line)
if parts: if parts:
@ -151,7 +151,7 @@ def writeListings(aout, infile_name, ref_prefix):
code_identation = " " code_identation = " "
skip_code = 0 skip_code = 0
with open(infile_name, 'rb') as fin: with open(infile_name, 'r') as fin:
for line in fin: for line in fin:
if state == State.SearchExampleStart: if state == State.SearchExampleStart:
parts = re.match('.*(EXAMPLE_START)\((.*)\):\s*(.*)(\*/)?\n',line) parts = re.match('.*(EXAMPLE_START)\((.*)\):\s*(.*)(\*/)?\n',line)
@ -267,12 +267,12 @@ def writeListings(aout, infile_name, ref_prefix):
def processExamples(intro_file, examples_folder, examples_ofile): def processExamples(intro_file, examples_folder, examples_ofile):
with open(examples_ofile, 'w') as aout: with open(examples_ofile, 'w') as aout:
with open(intro_file, 'rb') as fin: with open(intro_file, 'r') as fin:
for line in fin: for line in fin:
aout.write(line) aout.write(line)
for group_title in list_of_groups: for group_title in list_of_groups:
if not list_of_examples.has_key(group_title): continue if not group_title in list_of_examples.keys(): continue
examples = list_of_examples[group_title] examples = list_of_examples[group_title]
for example in examples: for example in examples:
example_path = examples_folder + example[0] + "/" + example[0] + ".ino" example_path = examples_folder + example[0] + "/" + example[0] + ".ino"
@ -283,7 +283,7 @@ def processExamples(intro_file, examples_folder, examples_ofile):
aout.write("\n\n"); aout.write("\n\n");
for group_title in list_of_groups: for group_title in list_of_groups:
if not list_of_examples.has_key(group_title): continue if not group_title in list_of_examples.keys(): continue
examples = list_of_examples[group_title] examples = list_of_examples[group_title]
group_title = group_title + " example" group_title = group_title + " example"
@ -301,7 +301,7 @@ def processExamples(intro_file, examples_folder, examples_ofile):
aout.write("\n") aout.write("\n")
for group_title in list_of_groups: for group_title in list_of_groups:
if not list_of_examples.has_key(group_title): continue if not group_title in list_of_examples.keys(): continue
examples = list_of_examples[group_title] examples = list_of_examples[group_title]
for example in examples: for example in examples:

View File

@ -261,7 +261,7 @@ def create_wrapper(fout, type_and_name, arg_string, need_lock):
num_functions += 1 num_functions += 1
def write_wrappers_for_file(fout, file, header_name, need_lock): def write_wrappers_for_file(fout, file, header_name, need_lock):
with open(file, 'rb') as fin: with open(file, 'r') as fin:
typedefFound = 0 typedefFound = 0
multiline_function_def = 0 multiline_function_def = 0
multiline = '' multiline = ''