Skip to contentSkip to conversation

scripts: standardize print usage with parentheses

PATCH In review Lucas Dutra Nunes 2 participants 6 messages Mar 1, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 scripts: standardize print usage with parentheses

---
 scripts/bitbake-metadata2doc.py |  2 +-
 scripts/format_machine_list.py  |  2 +-
 scripts/generate-bugs-table.py  | 14 +++++++-------
 scripts/test-sheet-parser.py    |  2 +-
 4 files changed, 10 insertions(+), 10 deletions(-)
scripts/bitbake-metadata2doc.py +1 -1
index 095e6a9..0149dd4 100644
@@ -478,7 +478,7 @@ def write_acknowledgements(out_dir, bsp_dir, gitdm_dir, start_commit, end_commit
 
 
 def usage(exit_code=None):
-    print 'Usage: %s <data file> <output dir> <bsp dir> <gitdb dir> <start commit> <end commit>' % (os.path.basename(sys.argv[0]),)
+    print('Usage: %s <data file> <output dir> <bsp dir> <gitdb dir> <start commit> <end commit>' % (os.path.basename(sys.argv[0]),))
     if exit_code:
         sys.exit(exit_code)
 
scripts/format_machine_list.py +1 -1
index 989a6d7..07f1437 100755
@@ -38,7 +38,7 @@ def main():
 
     csv_file = sys.argv[1]
     table = process_machines_table(read_csv_file(csv_file))
-    print table.strip()
+    print(table.strip())
 
 
 if __name__ == '__main__':
scripts/generate-bugs-table.py +7 -7
index 094efde..8f82bde 100755
@@ -44,20 +44,20 @@ def parse_data(csv_bug_list, columns_to_keep):
 
 def write_to_file(file_path, data):
     if(file_path == "-"):
-        print "\n" + data
+        print("\n" + data)
     else:
-        print 'Writing to file "' + file_path + '"...'
+        print('Writing to file "' + file_path + '"...')
         f = open(file_path, 'w')
         f.write(data)
         f.close()
-        print "Done!"
+        print("Done!")
 
 def generate_bugs_file(url, output_file_path, columns_to_keep):
-    print "Requesting bugs list in CSV format from https://bugzilla.yoctoproject.org/..."
+    print("Requesting bugs list in CSV format from https://bugzilla.yoctoproject.org/...")
     csv_bug_list = request_bug_list(url)
-    print "Parsing data..."
+    print("Parsing data...")
     data = parse_data(csv_bug_list, columns_to_keep)
-    print "Building table..."
+    print("Building table...")
     table = tabularize(data)
     write_to_file(output_file_path, table)
 
@@ -120,7 +120,7 @@ def process_arguments():
                   "YYYY-MM-DD")
             exit(1)
 
-    print start_processing_message
+    print(start_processing_message)
     url = re.sub('<<START_DATE>>', start_date, url)
     return [url, output, columns_to_keep]
 
scripts/test-sheet-parser.py +1 -1
index 39c84bb..71f8ba7 100755
@@ -168,7 +168,7 @@ def process_test_sheet(test_sheet, repos_dir):
         print('This board was tested by %d %s.\n' % (len(testers), tester_str))
         print('%d %s %s used:\n' % (len(images), image_str, was))
         for image in images:
-            print '  * ' + image
+            print('  * ' + image)
 
         # Omit the first 4 questions (personal + board) and empty questions
         # for qno, question in enumerate(header):
Signature · 1 line
2.1.4
#1 lore raw

PATCH 2/3 scripts: remove commented code

---
 scripts/test-sheet-parser.py | 16 ----------------
 1 file changed, 16 deletions(-)
scripts/test-sheet-parser.py +0 -16
index 71f8ba7..17dded3 100755
@@ -131,10 +131,6 @@ def process_test_sheet(test_sheet, repos_dir):
     board_index = fields.index('board')
     supported_boards = get_supported_boards(repos_dir)
 
-
-    # for row in test_sheet:
-    #     print row
-
     for response in responses:
         board = response[board_index]
         if board not in responses_by_board.keys():
@@ -163,23 +159,11 @@ def process_test_sheet(test_sheet, repos_dir):
             image_str = 'image'
             was = 'was'
 
-
-
         print('This board was tested by %d %s.\n' % (len(testers), tester_str))
         print('%d %s %s used:\n' % (len(images), image_str, was))
         for image in images:
             print('  * ' + image)
 
-        # Omit the first 4 questions (personal + board) and empty questions
-        # for qno, question in enumerate(header):
-        #     if qno > 3 and question != '':
-        #         print(rst_item(question))
-        #         for responses in responses_by_board[board]:
-        #             resp = responses[qno]
-        #             if resp:
-        #                 print(rst_item(resp, level=1))
-        #         print('')
-
         print('\n')
 
     not_tested = set(supported_boards.keys()) - set(responses_by_board.keys())
Signature · 1 line
2.1.4
#3 lore raw

PATCH 3/3 scripts: output error messages to stderr

In reply to Lucas Dutra Nunes
---
 scripts/format_machine_list.py | 2 +-
 scripts/generate-bugs-table.py | 7 ++++---
 scripts/test-sheet-parser.py   | 4 ++--
 3 files changed, 7 insertions(+), 6 deletions(-)
scripts/format_machine_list.py +1 -1
index 07f1437..778d4fc 100755
@@ -14,7 +14,7 @@ def read_csv_file(csv_file):
             reader = csv.reader(csv_fd, delimiter=',')
             return list(reader)
     except IOError:
-        print('Could not read %s.  Aborting.') % csv_file
+        sys.stderr.write('Could not read %s.  Aborting.\n') % csv_file
         sys.exit(1)
 
 
scripts/generate-bugs-table.py +4 -3
index 8f82bde..e9829bd 100755
@@ -115,9 +115,10 @@ def process_arguments():
         try:
             time.strptime(start_date, "%Y-%m-%d")
         except ValueError:
-            print(os.path.basename(sys.argv[0]) +
-                  ": error: start_date must be in the following format: " +
-                  "YYYY-MM-DD")
+            msg = (os.path.basename(sys.argv[0]) +
+                   ": error: start_date must be in the following format: " +
+                   "YYYY-MM-DD")
+            sys.stderr.write(msg)
             exit(1)
 
     print(start_processing_message)
scripts/test-sheet-parser.py +2 -2
index 17dded3..bb6f5da 100755
@@ -49,7 +49,7 @@ def read_test_sheet(csv_file):
             reader = csv.reader(csv_fd, delimiter=',')
             return list(reader)
     except IOError:
-        print('Could not read %s.  Aborting.') % csv_file
+        sys.stderr.write('Could not read %s.  Aborting.\n') % csv_file
         sys.exit(1)
 
 def parse_board_file(board_file):
@@ -65,7 +65,7 @@ def parse_board_file(board_file):
                     board_spec['soc'] = get_descr(line)
             return board_spec
     except IOError:
-        print('Could not read %s.') % board_file
+        sys.stderr.write('Could not read %s.\n') % board_file
 
 
 def get_supported_boards(repos_dir):
Signature · 1 line
2.1.4