diff --git a/tools/generate.py b/tools/generate.py index 9fa3ad505..1816a721d 100755 --- a/tools/generate.py +++ b/tools/generate.py @@ -6,10 +6,10 @@ import re import sys import os -print ''' +print(''' Java binding generator for BTstack Copyright 2014, BlueKitchen GmbH -''' +''') # com.bluekitchen.btstack.BTstack.java templates java_btstack_header = \ @@ -162,7 +162,7 @@ def camel_case_var(name): def read_defines(infile): global defines - with open (infile, 'rb') as fin: + with open (infile, 'rt') as fin: for line in fin: parts = re.match('#define\s+(\w+)\s+(\w*)',line) @@ -274,11 +274,11 @@ def parse_commands(infile): outfile = '%s/BTstack.java' % gen_path - with open(outfile, 'w') as fout: + with open(outfile, 'wt') as fout: fout.write(java_btstack_header % package) - with open (infile, 'rb') as fin: + with open (infile, 'rt') as fin: params = [] for line in fin: @@ -346,7 +346,7 @@ def create_event(event_name, format, args): gen_event_path = '%s/event' % gen_path outfile = '%s/%s.java' % (gen_event_path, event_name) - with open(outfile, 'w') as fout: + with open(outfile, 'wt') as fout: offset = 2 getters = '' length_name = '' @@ -399,7 +399,7 @@ def create_event_factory(events, le_events, defines): event_name = camel_case(event_name) subcases += java_event_factory_subevent.format(event_type, event_name) - with open(outfile, 'w') as fout: + with open(outfile, 'wt') as fout: defines_text = java_defines_string(defines) fout.write(java_event_factory_template.format(package, defines_text, cases, subcases)) @@ -410,7 +410,7 @@ def parse_events(path): params = [] event_types = set() format = None - with open (path, 'rb') as fin: + with open (path, 'rt') as fin: for line in fin: parts = re.match('.*@format\s*(\w*)\s*', line) if parts and len(parts.groups()) == 1: @@ -448,4 +448,4 @@ create_events(le_events) create_event_factory(events, le_events, event_types) # done -print 'Done!' +print('Done!') diff --git a/tools/update_copyright.py b/tools/update_copyright.py index e67d4b5f3..f49abfd89 100644 --- a/tools/update_copyright.py +++ b/tools/update_copyright.py @@ -60,13 +60,13 @@ def updateCopyright(dir_name, file_name): #print "Update copyright: ", infile - with open(outfile, 'w') as fout: + with open(outfile, 'wt') as fout: fout.write(copyright) bufferComment = "" state = State.SearchStartComment - with open(infile, 'rb') as fin: + with open(infile, 'rt') as fin: for line in fin: if state == State.SearchStartComment: parts = re.match('\s*(/\*).*(\*/)',line) @@ -129,11 +129,11 @@ def requiresCopyrightUpdate(file_name): return True if onlyDumpDifferentCopyright: - print file_name, ": Copyrighter not allowed > ", parts.group() + print(file_name, ": Copyrighter not allowed > ", parts.group()) return False if not exactCopyrightFound: - print file_name, ": File has no copyright" + print(file_name, ": File has no copyright") return False