-
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea773fd
commit 60bd6e3
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import glob, os | ||
|
||
|
||
|
||
|
||
OLDSTR = b"2021" | ||
|
||
NEWSTR = b"""2022""" | ||
|
||
input(f"Path is \"{os.getcwd()}\" Press [INTRO] to contniue") | ||
print() | ||
print() | ||
print("Lang files to update: ") | ||
|
||
for ext in ["py", "txt", "md", "html", "js"]: | ||
for file in glob.glob(f"**/*.{ext}", recursive=True): | ||
if "year_update" not in file: | ||
print(" -", file) | ||
print() | ||
input("Press [INTRO] to contniue") | ||
|
||
print() | ||
print() | ||
print("old string:", OLDSTR) | ||
print("new string:", NEWSTR) | ||
print() | ||
input("Press [INTRO] to contniue") | ||
|
||
for ext in ["py", "txt", "md", "html", "js"]: | ||
for file in glob.glob(f"**/*.{ext}", recursive=True): | ||
print("Processing", file, "...") | ||
if "year_update" not in file: | ||
try: | ||
with open(file, "rb") as f: | ||
contents = f.read() | ||
if OLDSTR in contents: | ||
with open(file, "wb") as f: | ||
f.write(contents.replace(OLDSTR, NEWSTR)) | ||
|
||
print("🟢", file, "has been updated successfully") | ||
else: | ||
print("⚪", file, "has no occurrences of the substring") | ||
except Exception as e: | ||
print("🟥", file, "has not been updated:", str(e)) | ||
|
||
input("Finished, press [INTRO] to close") |