Created
January 27, 2016 16:34
-
-
Save 13steinj/a5bfefa37b97eede36c9 to your computer and use it in GitHub Desktop.
Update's reddit's headers to the current year
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from datetime import datetime | |
skipped_endings = ['.so', '.pyc', '.ico', '.png', '.jpg', '.jpeg', '.gif', '.o'] | |
skipped_files = [ | |
'r2/r2/public/static/inbound-email-policy.html' # when this file gets run through, something happens to it's endings, I don't know legal validity stuff. | |
] | |
current_year_digits = int(str(datetime.now().year)[2:]) | |
file_list = [] | |
for walker in os.walk('reddit'): | |
if walker[2]: | |
for file in walker[2]: | |
file_list.append(os.path.join(walker[0], file)) | |
else: | |
file_list.append(walker[0]) | |
file_list = [f for f in file_list if os.path.isfile(f) and ('.git/' not in f)] | |
for filename in file_list: | |
if any(filename.endswith(ending) for ending in skipped_endings): | |
continue | |
if any(filename.endswith(skipped) for skipped in skipped_files): | |
continue | |
file = open(filename, 'r') | |
print(filename) | |
data = file.read() | |
for i in range(6, current_year_digits): | |
data = data.replace( | |
"All portions of the code written by reddit are Copyright (c) 2006-20{0}".format(i), | |
"All portions of the code written by reddit are Copyright (c) 2006-20{0}".format(current_year_digits) | |
) | |
data = data.replace( | |
"Attribution Copyright Notice: Copyright (c) 2006-20{0} reddit Inc. All Rights".format(i), | |
"Attribution Copyright Notice: Copyright (c) 2006-20{0} reddit Inc. All Rights".format(current_year_digits) | |
) | |
file.close() | |
file = open(filename, 'w') | |
file.write(data) | |
file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment