From 1c68226ab90b9390d3a31256ec755b2a0799f4e7 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Sat, 15 Apr 2023 18:13:37 -0400 Subject: [PATCH] port-jobs: No longer remove shebang with COMMENTS.py Former-commit-id: 7b67fcdcfa2993ef7967f2300b979c321e5966c2 Former-commit-id: 0e88fa41dcc7dfa0f1d69ebefa48c5f5d56739cc --- port-jobs/COMMENTS.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/port-jobs/COMMENTS.py b/port-jobs/COMMENTS.py index 1890576..cdfd2e1 100755 --- a/port-jobs/COMMENTS.py +++ b/port-jobs/COMMENTS.py @@ -13,12 +13,17 @@ for filename in listdir('working'): # read input file with open(filepath, 'r') as file: new_file = [] + first_line = True for line in file: # determine whether to remove all or only PORT comments - if len(arguments) > 0 and arguments[0] == 'ALL': - if not rematch(r'^\s*#', line): - new_file.append(line) - elif not rematch(r'^\s*# PORT', line): + if first_line: new_file.append(line) + first_line = False + else: + if len(arguments) > 0 and arguments[0] == 'ALL': + if not rematch(r'^\s*#', line): + new_file.append(line) + elif not rematch(r'^\s*# PORT', line): + new_file.append(line) # write the updated file contents open(filepath, 'w').writelines(new_file)