From d060c67197ab285dbd2ca4efe311b99c8b26e720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Hells=C3=A9n?= Date: Mon, 3 Jan 2022 20:40:02 +0100 Subject: [PATCH] Move files to folders --- .vscode/launch.json | 39 ++++++++++++------------ discord_embed/__init__.py | 1 + main.py => discord_embed/main.py | 11 ++----- settings.py => discord_embed/settings.py | 0 tests/__init__.py | 0 tests/test_discord_embed.py | 5 +++ 6 files changed, 27 insertions(+), 29 deletions(-) create mode 100644 discord_embed/__init__.py rename main.py => discord_embed/main.py (97%) rename settings.py => discord_embed/settings.py (100%) create mode 100644 tests/__init__.py create mode 100644 tests/test_discord_embed.py diff --git a/.vscode/launch.json b/.vscode/launch.json index 4f58b6b..24324ce 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,21 +1,20 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python: FastAPI", - "type": "python", - "request": "launch", - "module": "uvicorn", - "args": [ - "main:app" - ], - "env": { - "DOMAIN": "http://127.0.0.1:8000/" - }, - "jinja": true - } - ] -} \ No newline at end of file + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: FastAPI", + "type": "python", + "request": "launch", + "module": "uvicorn", + "args": ["discord_embed.main:app"], + "env": { + "DOMAIN": "http://127.0.0.1:8000/", + "UPLOAD_FOLDER": "uploads" + }, + "jinja": true + } + ] +} diff --git a/discord_embed/__init__.py b/discord_embed/__init__.py new file mode 100644 index 0000000..3dc1f76 --- /dev/null +++ b/discord_embed/__init__.py @@ -0,0 +1 @@ +__version__ = "0.1.0" diff --git a/main.py b/discord_embed/main.py similarity index 97% rename from main.py rename to discord_embed/main.py index 203d3dc..bf8b1eb 100644 --- a/main.py +++ b/discord_embed/main.py @@ -1,8 +1,3 @@ -"""Website for uploading files, creating .HTMLs, and thumbnails. - -This was created for Discord. You can use this to embed videos in Discord. -""" - import sys from datetime import datetime from pathlib import Path @@ -16,7 +11,7 @@ from pygments import highlight from pygments.formatters import HtmlFormatter from pygments.lexers import guess_lexer -from settings import Settings +from discord_embed.settings import Settings hook = Webhook(Settings.webhook_url) app = FastAPI( @@ -61,8 +56,6 @@ def video_file_uploaded(file: UploadFile) -> Dict[str, str]: Returns: Dict[str, str]: Returns URL for video. """ - # Make custom html for video files. - # Create folder if it doesn't exist. Path(f"{Settings.upload_folder}/video").mkdir(parents=True, exist_ok=True) @@ -102,7 +95,7 @@ def text_file_uploaded(file: UploadFile) -> Dict[str, str]: lines = file_object.read() colored_text = highlight( lines, - guess_lexer(lines), # Guess + guess_lexer(lines), HtmlFormatter( style="fruity", # Dark style linenos="table", # Output line numbers as a table w/ two cells, one with line numbers, other with code diff --git a/settings.py b/discord_embed/settings.py similarity index 100% rename from settings.py rename to discord_embed/settings.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_discord_embed.py b/tests/test_discord_embed.py new file mode 100644 index 0000000..2de2b95 --- /dev/null +++ b/tests/test_discord_embed.py @@ -0,0 +1,5 @@ +from discord_embed import __version__ + + +def test_version(): + assert __version__ == "0.1.0"