Skip to content

Commit

Permalink
Merge pull request #16 from SkwalExe/pypi-publishing
Browse files Browse the repository at this point in the history
prepare package for pypi publishing
  • Loading branch information
SkwalExe authored May 28, 2024
2 parents 66ec277 + c0c9003 commit b78ca76
Show file tree
Hide file tree
Showing 17 changed files with 1,262 additions and 36 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Byte-compiled / optimized / DLL files
.pdm-python

__pycache__/
*.py[cod]
*$py.class
Expand Down Expand Up @@ -157,4 +159,4 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# 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/
#.idea/
1 change: 0 additions & 1 deletion output/info.txt

This file was deleted.

1,187 changes: 1,187 additions & 0 deletions pdm.lock

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"

[project]
name = "octologo"
version = "3.0.0"
description = "Simple program that generates a logo for your open source projects."
authors = [{name = "Leopold Koprivnik", email = "[email protected]"}]
readme = "README.md"
license = {file = "LICENSE"}
classifiers = ["License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)"]
requires-python = ">=3.9"
dependencies = [
"pillow==10.2.0",
"inquirer==3.1.3",
"toml==0.10.2",
"importlib==1.0.4",
"textual==0.38.1",
"click-extra==4.7.2",
"loguru==0.7.2"
]

[project.urls]
Home = "https://github.com/SkwalExe/octo-logo"

[project.scripts]
octologo = "octologo.__main__:main"

[tool.pdm]
distribution = true

7 changes: 0 additions & 7 deletions requirements.txt

This file was deleted.

3 changes: 3 additions & 0 deletions src/octologo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Simple program that generates a logo for your open source projects"""

__version__ = "3.0.0"
52 changes: 31 additions & 21 deletions src/main.py → src/octologo/__main__.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
import os
from time import time
from utils import BASE_DIR, style_names, styles, logger
from wizard import TextQuestion, SelectQuestion, Wizard, inq_ask
from octologo.utils import BASE_DIR, style_names, styles, logger
from octologo import __version__
from octologo.wizard import TextQuestion, SelectQuestion, Wizard, inq_ask
from textual.app import App
from textual.widgets import Header, Footer, Label, LoadingIndicator
from textual.validation import Length
from PIL import Image
from textual.events import Key
from click_extra import extra_command, option, ExtraContext, Parameter
# from textual import log

VERSION = "1.1.1"
# from textual import log

BASIC_INFO_QUESTIONS = [
TextQuestion(
"name",
"Your project's name",
[Length(1, failure_description="Your project's name cannot be blank")],
"super-octo-project"),
SelectQuestion("style", "Logo Style", style_names, "first_letter_underlined")
[Length(1, failure_description="Your project's name cannot be blank")],
"super-octo-project",
),
SelectQuestion("style", "Logo Style", style_names, "first_letter_underlined"),
]


def get_output_filaname(project_name):
return f"octologo_{project_name}_{int(time())}.png"


class OctoLogoApp(App):
BINDINGS = [
("ctrl+q", "quit", "Quit"),
("ctrl+t", "toggle_dark", "Toggle Dark Mode")
("ctrl+t", "toggle_dark", "Toggle Dark Mode"),
]
answers = dict()

CSS_PATH = os.path.join(BASE_DIR, "src", "app.tcss")
CSS_PATH = os.path.join(BASE_DIR, "app.tcss")
TITLE = "Octo Logo Wizard"
finished: bool = False
save_to: str | None = None
Expand All @@ -53,29 +58,32 @@ def on_wizard_finished(self, message: Wizard.Finished):
# When the basic info wizard is finished, mount the style-specific wizard
if finished_wizard_id == "basic_info_wizard":
style_wizard = Wizard(id="style_wizard")
style_wizard.questions = styles[self.answers['style']].module.questions
style_wizard.questions = styles[self.answers["style"]].module.questions
style_wizard.title = "Style Settings"
self.mount(style_wizard)
# When the style-specific wizard is finished, create the image and save it
elif finished_wizard_id == "style_wizard":
style = styles[self.answers['style']].module
style = styles[self.answers["style"]].module
self.result = style.get_image(self.answers)
self.save_to = f'output/{self.answers["name"]}_{int(time())}.png'
self.save_to = get_output_filaname(self.answers["name"])
self.loading_wid.remove_class("hidden")
self.set_timer(2, self.final_message)

# Final message
def final_message(self):
self.loading_wid.add_class("hidden")
self.mount(Label(
f"Logo saved to [bold]{self.save_to}[/bold].\n"
f"[blue blink]-> Press v to view the result[/blue blink]\n"
f"[red]Press enter to quit[/red]"))
self.mount(
Label(
f"Logo saved to [bold]{self.save_to}[/bold].\n"
f"[blue blink]-> Press v to view the result[/blue blink]\n"
f"[red]Press enter to quit[/red]"
)
)
self.result.save(self.save_to)
self.finished = True

def compose(self):
self.app.title = f"Octo Logo v{VERSION}"
self.app.title = f"Octo Logo v{__version__}"

yield Header(show_clock=True)
yield Footer()
Expand All @@ -95,7 +103,9 @@ def disable_ansi(ctx: ExtraContext, param: Parameter, val: bool):


@extra_command(params=[])
@option("-t", "--no-tui", is_flag=True, help="Dont use the Textual Terminal User Interface")
@option(
"-t", "--no-tui", is_flag=True, help="Dont use the Textual Terminal User Interface"
)
def main(no_tui: bool):
use_tui = not no_tui

Expand All @@ -109,11 +119,11 @@ def main(no_tui: bool):
answers = dict()

answers.update(inq_ask(BASIC_INFO_QUESTIONS))
answers.update(inq_ask(styles[answers['style']].module.questions))
answers.update(inq_ask(styles[answers["style"]].module.questions))

style = styles[answers['style']].module
style = styles[answers["style"]].module
result = style.get_image(answers)
save_to = f'output/{answers["name"]}_{int(time())}.png'
save_to = get_output_filaname(answers["name"])

result.save(save_to)
logger.success(f"Image saved to : {save_to}")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from wizard import TextQuestion, SelectQuestion
from octologo.wizard import TextQuestion, SelectQuestion
from textual.validation import Number
from utils import font_list, color_scheme_names, FONTS_DIR, color_schemes, os, get_font_height, get_text_size
from octologo.utils import font_list, color_scheme_names, FONTS_DIR, color_schemes, os, get_font_height, get_text_size
from PIL import Image, ImageDraw, ImageFont, ImageColor
import sys

Expand Down
6 changes: 3 additions & 3 deletions src/utils.py → src/octologo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, display_name: str, module: Any) -> None:
self.module = module


BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
FONTS_DIR = os.path.join(BASE_DIR, "fonts")
COLORS_DIR = os.path.join(BASE_DIR, "colors")

Expand Down Expand Up @@ -85,12 +85,12 @@ def get_styles() -> dict[str, Style]:
"""
# Load the styles in the styles directory
styles = dict()
for style in os.listdir(os.path.join(BASE_DIR, "src", "styles")):
for style in os.listdir(os.path.join(BASE_DIR, "styles")):
# Only keep .py files
if not style.endswith(".py"):
continue

module = import_module(f"styles.{remove_ext(style)}")
module = import_module(f"octologo.styles.{remove_ext(style)}")

# Only keep files with the active attribute set to True
# This allows to ignore some scripts that may be in the styles directory
Expand Down
2 changes: 1 addition & 1 deletion src/wizard.py → src/octologo/wizard.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from utils import logger
from octologo.utils import logger
from typing import Any
from textual.validation import Validator
from textual.widgets import Input, Select, Static, Button, Label
Expand Down

0 comments on commit b78ca76

Please sign in to comment.