initial commit
21
.forgejo/workflows/release.yml
Normal file
|
@ -0,0 +1,21 @@
|
|||
name: Upload release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "*"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build with Make
|
||||
run: make
|
||||
|
||||
- name: Create release
|
||||
uses: akkuman/gitea-release-action@v1
|
||||
with:
|
||||
token: ${{ secrets.TOKEN }}
|
||||
files: horoscope.bat
|
12
.gitignore
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
.vscode/
|
||||
|
||||
bin/
|
||||
lib/
|
||||
|
||||
pyvenv.cfg
|
||||
|
||||
horoscope.bat
|
||||
|
||||
*.png
|
||||
|
||||
!images/*
|
14
Makefile
Normal file
|
@ -0,0 +1,14 @@
|
|||
HEADER = header.bat
|
||||
PYTHON = main.py
|
||||
|
||||
OUTPUT = horoscope.bat
|
||||
|
||||
all: build
|
||||
|
||||
build:
|
||||
cat $(HEADER) > $(OUTPUT)
|
||||
echo "" >> $(OUTPUT)
|
||||
echo "::python_beg" >> $(OUTPUT)
|
||||
cat $(PYTHON) >> $(OUTPUT)
|
||||
echo "" >> $(OUTPUT)
|
||||
echo "::python_end" >> $(OUTPUT)
|
61
header.bat
Normal file
|
@ -0,0 +1,61 @@
|
|||
@ECHO OFF
|
||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||
|
||||
SET "tmpFile=%TEMP%\~horoscope.py"
|
||||
|
||||
:: Variables
|
||||
SET "pipR=pip install Pillow"
|
||||
SET "py=python.exe"
|
||||
|
||||
:: Check python installation
|
||||
!py! --version >NUL
|
||||
|
||||
:: Clean potential error or python version
|
||||
CLS
|
||||
|
||||
IF ERRORLEVEL 1 (
|
||||
ECHO Installation of Python not found, installation...
|
||||
|
||||
:: Install Python 3.11 from MS Store
|
||||
ECHO Y | winget install -he 9NRWMJP3717K
|
||||
|
||||
ECHO Download and installation of dependencies...
|
||||
|
||||
:: Location of Python
|
||||
SET "py=%LOCALAPPDATA%\Microsoft\WindowsApps\!py!"
|
||||
|
||||
:: Update pip
|
||||
!py! -m pip install --upgrade pip
|
||||
|
||||
:: Install dependencies
|
||||
!py! -m !pipR!
|
||||
) ELSE (
|
||||
:: Check dependencies
|
||||
!py! -m !pipR! >NUL
|
||||
)
|
||||
|
||||
:: Download images under %TEMP%\images
|
||||
REM TODO
|
||||
|
||||
:: Write the program
|
||||
CALL :getLine "::python_beg" "::python_end" > "!tmpFile!"
|
||||
|
||||
:: Run the program
|
||||
PowerShell -Command "Start-Process cmd -Argument '/c START /B python !tmpFile!' -WindowStyle hidden"
|
||||
EXIT /B
|
||||
|
||||
:getLine <beg str> <end str>
|
||||
SET "bBegEnd=0"
|
||||
FOR /F "usebackq delims=" %%i IN ("%~f0") do (
|
||||
IF !bBegEnd! EQU 1 (
|
||||
IF "%%i" EQU "%~2" ( EXIT /B )
|
||||
SETLOCAL DISABLEDELAYEDEXPANSION
|
||||
ECHO %%i
|
||||
ENDLOCAL
|
||||
) ELSE (
|
||||
IF "%%i" EQU "%~1" ( SET "bBegEnd=1" )
|
||||
)
|
||||
)
|
||||
|
||||
ENDLOCAL
|
||||
EXIT /B
|
BIN
images/balance.png
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
images/belier.png
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
images/cancer.png
Normal file
After Width: | Height: | Size: 33 KiB |
BIN
images/capricorne.png
Normal file
After Width: | Height: | Size: 33 KiB |
BIN
images/gemeaux.png
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
images/lion.png
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
images/poissons.png
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
images/sagittaire.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
images/scorpion.png
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
images/taureau.png
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
images/verseau.png
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
images/vierge.png
Normal file
After Width: | Height: | Size: 30 KiB |
72
main.py
Normal file
|
@ -0,0 +1,72 @@
|
|||
from random import choice
|
||||
from os.path import join
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
zodiac_signs = [
|
||||
"Belier",
|
||||
"Taureau",
|
||||
"Gemeaux",
|
||||
"Cancer",
|
||||
"Lion",
|
||||
"Vierge",
|
||||
"Balance",
|
||||
"Scorpion",
|
||||
"Sagittaire",
|
||||
"Capricorne",
|
||||
"Verseau",
|
||||
"Poissons",
|
||||
]
|
||||
|
||||
|
||||
def generate_horoscope():
|
||||
horoscope = {}
|
||||
for sign in zodiac_signs:
|
||||
heart = choice(["+", "++", "+++", "-", "--"])
|
||||
work = choice(["+", "++", "+++", "-", "--"])
|
||||
|
||||
if heart.count("+") > 3:
|
||||
heart = "+++"
|
||||
elif heart.count("-") > 2:
|
||||
heart = "--"
|
||||
|
||||
if work.count("+") > 3:
|
||||
work = "+++"
|
||||
elif work.count("-") > 2:
|
||||
work = "--"
|
||||
|
||||
horoscope[sign] = {"heart": heart, "work": work}
|
||||
|
||||
return horoscope
|
||||
|
||||
|
||||
def create_horoscope_image(horoscope):
|
||||
img_width, img_height = 800, 600
|
||||
image = Image.new("RGBA", (img_width, img_height), color="white")
|
||||
draw = ImageDraw.Draw(image, "RGBA")
|
||||
|
||||
font = ImageFont.load_default()
|
||||
|
||||
x, y = 20, 20
|
||||
for sign, prediction in horoscope.items():
|
||||
sign_image = Image.open(join("images", f"{sign.lower()}.png"))
|
||||
image.paste(sign_image, (x, y))
|
||||
|
||||
draw.text((x, y), sign, fill="black", font=font)
|
||||
draw.text((x, y + 30), f"♥: {prediction['heart']}", fill="red", font=font)
|
||||
draw.text((x, y + 60), f"💼: {prediction['work']}", fill="blue", font=font)
|
||||
|
||||
x += 200
|
||||
if x > 600:
|
||||
x = 20
|
||||
y += 150
|
||||
|
||||
return image
|
||||
|
||||
|
||||
new_horoscope = generate_horoscope()
|
||||
|
||||
horoscope_image = create_horoscope_image(new_horoscope)
|
||||
|
||||
horoscope_image.save("nouvel_horoscope.png")
|
||||
|
||||
print("Nouvel horoscope généré et sauvegardé sous 'nouvel_horoscope.png'")
|
1
requirements.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Pillow==10.4.0
|