From a498477551af4e54bfa09f5ee1d6bbaf8f6056fe Mon Sep 17 00:00:00 2001 From: Bobby Date: Sat, 5 Nov 2022 06:43:35 -0400 Subject: refactor: auto sort and format code on commit --- .isort.cfg | 6 ++++++ commit.sh | 6 ++++++ scripts/maintainers.py | 29 +++++++++++++++++------------ src/texty.py | 6 +++++- 4 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 .isort.cfg diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 0000000..e74b905 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,6 @@ +# isort config file + +[settings] +skip_glob = env +profile = black +src_paths = src,scripts \ No newline at end of file diff --git a/commit.sh b/commit.sh index 405a9fc..575e237 100755 --- a/commit.sh +++ b/commit.sh @@ -40,6 +40,12 @@ commands() { # Example: # echo "Hello World" + # Sort imports + python3 -m isort . + + # Format code + python3 -m black . + # Generate Requirements.txt pipreqs --force . diff --git a/scripts/maintainers.py b/scripts/maintainers.py index 2ab3b0f..27639c0 100644 --- a/scripts/maintainers.py +++ b/scripts/maintainers.py @@ -4,37 +4,42 @@ import yaml + def main(): # Load the maintainers.yml file - with open('maintainers.yml', 'r') as f: + with open("maintainers.yml", "r") as f: maintainers = yaml.safe_load(f) # Load the README.md file - with open('README.md', 'r') as f: + with open("README.md", "r") as f: readme = f.read() # Generate the list of maintainers maintainers_list = "" maintainer_images = "" for maintainer in maintainers: - if not maintainer['name'] or not maintainer['github']: + if not maintainer["name"] or not maintainer["github"]: # Skip maintainers without a name or github username continue # Generate the markdown for the maintainer - maintainers_list += "- [{}]({})".format(maintainer['name'], maintainer['github']) - if maintainer['email']: - maintainers_list += "<{}>".format(maintainer['email']) + maintainers_list += "- [{}]({})".format( + maintainer["name"], maintainer["github"] + ) + if maintainer["email"]: + maintainers_list += "<{}>".format(maintainer["email"]) - if maintainer['website']: - maintainers_list += " - [{}]({})".format(maintainer['website'], maintainer['website']) + if maintainer["website"]: + maintainers_list += " - [{}]({})".format( + maintainer["website"], maintainer["website"] + ) # Move to next line maintainers_list += "\r" # Generate the markdown for the maintainer's image - image_url = "https://github.com/{}.png?size=40".format(maintainer['github']) - maintainer_images += "![{}]({}) ".format(maintainer['name'], image_url) + image_url = "https://github.com/{}.png?size=40".format(maintainer["github"]) + maintainer_images += "![{}]({}) ".format(maintainer["name"], image_url) # Remove everything below "" in the README.md file readme = readme.split("")[0] @@ -43,9 +48,9 @@ def main(): readme += "\r" + maintainers_list + "\r" + maintainer_images # Save the README.md file - with open('README.md', 'w') as f: + with open("README.md", "w") as f: f.write(readme) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/src/texty.py b/src/texty.py index e75154b..e9be7d1 100644 --- a/src/texty.py +++ b/src/texty.py @@ -1 +1,5 @@ -print("hello world") \ No newline at end of file +# Texty is a text editor written in Python using the Tkinter. It is a simple +# text editor focused on simplicity and ease of use while being powerful and +# extensible. It is a work in progress and is not yet ready for use. + +import tkinter as tk -- cgit v1.2.3