-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix utf-8 encoding errors, exclude relevant folders from parser, add …
….idea in .gitignore
- Loading branch information
1 parent
60091b2
commit 6701590
Showing
2 changed files
with
25 additions
and
20 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
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 |
---|---|---|
@@ -1,41 +1,46 @@ | ||
import os | ||
import pathlib | ||
import fnmatch | ||
import sys | ||
|
||
""" | ||
Run this script once after first creating the repository from the template. | ||
This script is interactive and will prompt you for various inputs. | ||
""" | ||
|
||
import os | ||
import pathlib | ||
import fnmatch | ||
from sys import argv | ||
|
||
|
||
if __name__ == "__main__": | ||
repo_name = input("What is the name of your plugin (full name with spaces) ? ") | ||
repo_name = input("What is the name of your plugin (full name with spaces)? ") | ||
|
||
snake_name = ("_").join(repo_name.lower().split(" ")) | ||
snake_name = "_".join(repo_name.lower().split(" ")) | ||
|
||
os.rename("my_plugin.py", f"{snake_name}.py") | ||
for file in pathlib.Path(".").glob('**/*.*'): | ||
|
||
for file in pathlib.Path(".").glob("**/*.*"): | ||
filename = str(file) | ||
if fnmatch.fnmatch(filename, ".git") or fnmatch.fnmatch(filename, ".git\*"): | ||
|
||
if fnmatch.fnmatch(filename, ".git/*"): # Exclude .git directory | ||
continue | ||
|
||
|
||
if fnmatch.fnmatch(filename, "__pycache__/*"): # Exclude __pycache__ directory | ||
continue | ||
|
||
if fnmatch.fnmatch(filename, sys.argv[0]): # Exclude the script file itself | ||
continue | ||
|
||
if os.path.basename(file) == "setup.py": | ||
continue | ||
|
||
if file.is_dir(): | ||
continue | ||
else: | ||
with open(file, "r") as f: | ||
with open(file, "r", encoding="utf-8", errors="ignore") as f: | ||
content = f.read() | ||
|
||
replaced = content.replace("my_plugin", snake_name).replace("My plugin", repo_name.title()) | ||
|
||
with open(file, "w") as f: | ||
with open(file, "w", encoding="utf-8", errors="ignore") as f: | ||
f.write(replaced) | ||
print(f"All the occurrencies were replaced successfully with `{repo_name}` !") | ||
os.remove(argv[0]) | ||
|
||
print(f"All the occurrences were replaced successfully with `{repo_name}`!") | ||
os.remove(sys.argv[0]) |