From b25f464a0493345a57053a5f2e4facf541eca464 Mon Sep 17 00:00:00 2001 From: Roland Thomas Date: Sat, 16 Sep 2023 16:51:31 -0400 Subject: [PATCH] Formatting --- .gitignore | 3 +++ bcrypt_test_db.py | 2 +- email_example.py | 3 ++- patch_example.py | 2 +- pyqttt.py => pyqt_tabs.py | 3 ++- rand_char.py | 3 ++- readline/creatures.py | 3 ++- readline/mtg.py | 3 ++- .../{crypto_server.py => generate_server_keys.py} | 2 +- secure_connection/secure_client.py | 13 +++++++------ secure_connection/secure_server.py | 3 ++- set_get_attr_example.py | 6 ++++-- thread_pool.py | 3 ++- 13 files changed, 31 insertions(+), 18 deletions(-) rename pyqttt.py => pyqt_tabs.py (98%) rename secure_connection/{crypto_server.py => generate_server_keys.py} (99%) diff --git a/.gitignore b/.gitignore index 68bc17f..69ab14c 100644 --- a/.gitignore +++ b/.gitignore @@ -158,3 +158,6 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + +# sqlite.db +*.db \ No newline at end of file diff --git a/bcrypt_test_db.py b/bcrypt_test_db.py index 89f67c0..5e3e3ac 100755 --- a/bcrypt_test_db.py +++ b/bcrypt_test_db.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -"""bcrypt_test.py +"""bcrypt_test_db.py This module provides utilities for user authentication, including functions to store hashed passwords, create new users, and authenticate existing users using bcrypt for password hashing and a sqlite database to store user data. diff --git a/email_example.py b/email_example.py index f7e9890..91483ad 100755 --- a/email_example.py +++ b/email_example.py @@ -1,4 +1,5 @@ -""" +"""email_example.py +---------------- This module sends an email with the contents of a specified text file as the body. The "smtplib" and "email.message" modules are used to construct and send the email. diff --git a/patch_example.py b/patch_example.py index 589bfd6..73366f8 100755 --- a/patch_example.py +++ b/patch_example.py @@ -3,7 +3,7 @@ import unittest from io import StringIO from unittest.mock import patch -import print_things +import print_things class TestPrintFunction(unittest.TestCase): diff --git a/pyqttt.py b/pyqt_tabs.py similarity index 98% rename from pyqttt.py rename to pyqt_tabs.py index e9f07c5..8e26b53 100755 --- a/pyqttt.py +++ b/pyqt_tabs.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 -""" +"""pyqt_tabs.py +---------------- This module contains a Python script utilizing the PyQt5 library to create a basic graphical user interface (GUI) application. The application showcases a tabbed window with two tabs, each containing a grid of numbers. The first tab diff --git a/rand_char.py b/rand_char.py index 77624b4..f8b7876 100755 --- a/rand_char.py +++ b/rand_char.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 -""" +"""rand_char.py +---------------- Generate and Print Random Unicode Characters This module generates a string of random Unicode characters, specifically diff --git a/readline/creatures.py b/readline/creatures.py index 361f1b0..fa476a8 100755 --- a/readline/creatures.py +++ b/readline/creatures.py @@ -1,5 +1,6 @@ #!/usr/bin/env -""" +"""creatures.py +---------------- This module implements a simple console application to manage a list of creatures. It provides functionalities to add a creature to the list, lookup creatures with autocomplete support (press tab to auto-complete creature names), and quit the diff --git a/readline/mtg.py b/readline/mtg.py index 0c67d69..e70c5a4 100755 --- a/readline/mtg.py +++ b/readline/mtg.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 -""" +"""mtg.py +---------------- This module defines a command-line interface (CLI) application which allows users to interact with a predefined list of completion options, specifically, card names from the "Alara Reborn" set. diff --git a/secure_connection/crypto_server.py b/secure_connection/generate_server_keys.py similarity index 99% rename from secure_connection/crypto_server.py rename to secure_connection/generate_server_keys.py index 3be0138..a5e6d4a 100755 --- a/secure_connection/crypto_server.py +++ b/secure_connection/generate_server_keys.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -"""crypto_server.py +"""generate_server_keys.py ---------------- This module contains utilities for generating and storing server keys and diff --git a/secure_connection/secure_client.py b/secure_connection/secure_client.py index 522ef22..0bb8a56 100755 --- a/secure_connection/secure_client.py +++ b/secure_connection/secure_client.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 -""" +"""secure_client.py +---------------- A module to establish a non-verifying SSL connection with a server and to send/receive messages through a secure socket. @@ -21,10 +22,10 @@ def main(server_address: str, server_port: int): context = SSLContext(PROTOCOL_TLS_CLIENT) context.check_hostname = False context.verify_mode = CERT_NONE - unsecure_socket: socket = create_connection( - (server_address, server_port) - ) - secure_socket = context.wrap_socket(unsecure_socket) #, server_hostname="localhost") + unsecure_socket: socket = create_connection((server_address, server_port)) + secure_socket = context.wrap_socket( + unsecure_socket + ) # , server_hostname="localhost") while True: message = input() @@ -36,4 +37,4 @@ def main(server_address: str, server_port: int): if __name__ == "__main__": - main("127.0.0.1", 9001) \ No newline at end of file + main("127.0.0.1", 9001) diff --git a/secure_connection/secure_server.py b/secure_connection/secure_server.py index 4839641..b86f2da 100755 --- a/secure_connection/secure_server.py +++ b/secure_connection/secure_server.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 -""" +"""secure_server.py +---------------- This module facilitates creating an asynchronous SSL server that echoes received messages. The server operates using SSL certificates stored in the "server_keys" directory. diff --git a/set_get_attr_example.py b/set_get_attr_example.py index ed9939a..4b2caf4 100755 --- a/set_get_attr_example.py +++ b/set_get_attr_example.py @@ -1,5 +1,5 @@ -""" -set_get_attr_example.py +# /usr/bin/env python3 +"""set_get_attr_example.py ----------------------- This module contains a class named `Number` which implements special attribute @@ -32,6 +32,7 @@ Note: but the `_number` value is printed instead of raising an AttributeError. """ + class Number: def __init__(self, number): self._number = number @@ -66,6 +67,7 @@ class Number: def __getattr__(self, name): return self._number + if __name__ == "__main__": number = Number(5) print(number.num) diff --git a/thread_pool.py b/thread_pool.py index 1952dcf..fe10159 100755 --- a/thread_pool.py +++ b/thread_pool.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 -""" +"""thread_pool.py +---------------- This module demonstrates the use of asyncio to handle asynchronous and blocking functions in Python. The module contains three functions: a blocking function that simulates a long-running process with `time.sleep`, an asynchronous