Skip to content
Snippets Groups Projects
Commit 36448048 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Scripts - update_license_headers.py:

- Code cleanup
- Not finished
parent d70cdd05
No related branches found
No related tags found
2 merge requests!235Release TeraFlowSDN 3.0,!224Resolve "Update license headers for Release 3"
...@@ -27,6 +27,7 @@ FILE_PATH_SKIPPED = 'out-skipped.txt' ...@@ -27,6 +27,7 @@ FILE_PATH_SKIPPED = 'out-skipped.txt'
FILE_PATH_NO_HEADER = 'out-no-header.txt' FILE_PATH_NO_HEADER = 'out-no-header.txt'
FILE_PATH_UPDATED = 'out-updated.txt' FILE_PATH_UPDATED = 'out-updated.txt'
STR_NEW_COPYRIGHT = 'Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG/SDG (https://tfs.etsi.org/)'
RE_OLD_COPYRIGHTS = [ RE_OLD_COPYRIGHTS = [
r'Copyright\ 2021\-2023\ H2020\ TeraFlow\ \(https\:\/\/www\.teraflow\-h2020\.eu\/\)', r'Copyright\ 2021\-2023\ H2020\ TeraFlow\ \(https\:\/\/www\.teraflow\-h2020\.eu\/\)',
r'Copyright\ 2022\-2023\ ETSI\ TeraFlowSDN\ \-\ TFS\ OSG\ \(https\:\/\/tfs\.etsi\.org\/\)', r'Copyright\ 2022\-2023\ ETSI\ TeraFlowSDN\ \-\ TFS\ OSG\ \(https\:\/\/tfs\.etsi\.org\/\)',
...@@ -36,8 +37,6 @@ RE_OLD_COPYRIGHTS = [ ...@@ -36,8 +37,6 @@ RE_OLD_COPYRIGHTS = [
for re_old_copyright in RE_OLD_COPYRIGHTS for re_old_copyright in RE_OLD_COPYRIGHTS
] ]
STR_NEW_COPYRIGHT = 'Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG/SDG (https://tfs.etsi.org/)'
def skip_file(file_path : str) -> bool: def skip_file(file_path : str) -> bool:
if os.path.islink(file_path): return True if os.path.islink(file_path): return True
if file_path.endswith('.pyc'): return True if file_path.endswith('.pyc'): return True
...@@ -80,16 +79,10 @@ def skip_file(file_path : str) -> bool: ...@@ -80,16 +79,10 @@ def skip_file(file_path : str) -> bool:
return False return False
def process_line(line_in : str) -> str: def process_line(line_in : str) -> str:
print('line_in', line_in)
for re_match, re_sub in RE_OLD_COPYRIGHTS: for re_match, re_sub in RE_OLD_COPYRIGHTS:
print('re_match', re_match)
print('re_sub', re_sub)
match = re_match.match(line_in) match = re_match.match(line_in)
print('match', match)
if match is None: continue if match is None: continue
print('matched!')
line_out = re_sub.sub(STR_NEW_COPYRIGHT, line_in) line_out = re_sub.sub(STR_NEW_COPYRIGHT, line_in)
print('line_out', line_out)
return line_out return line_out
return line_in return line_in
...@@ -123,8 +116,6 @@ def process_file( ...@@ -123,8 +116,6 @@ def process_file(
os.rename(temp_file_path, file_path) os.rename(temp_file_path, file_path)
os.chmod(file_path, file_stat.st_mode) os.chmod(file_path, file_stat.st_mode)
raise Exception()
def main() -> int: def main() -> int:
with open(FILE_PATH_NO_HEADER, 'w', encoding='UTF-8') as file_no_header: with open(FILE_PATH_NO_HEADER, 'w', encoding='UTF-8') as file_no_header:
with open(FILE_PATH_SKIPPED, 'w', encoding='UTF-8') as file_skipped: with open(FILE_PATH_SKIPPED, 'w', encoding='UTF-8') as file_skipped:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment