mirror of
https://github.com/aquatix/alfagok.git
synced 2025-12-06 18:45:10 +01:00
Initial version
This commit is contained in:
83
.gitignore
vendored
Normal file
83
.gitignore
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*,cover
|
||||
.hypothesis/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Logging:
|
||||
*.log
|
||||
*.log.*
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Ipython Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# Various Python project related
|
||||
local_settings.py
|
||||
projects.yaml
|
||||
settings.py
|
||||
|
||||
# IDE
|
||||
.idea
|
||||
|
||||
# vim
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# ctags
|
||||
tags
|
||||
TAGS
|
||||
|
||||
# settings
|
||||
settings.py
|
||||
rq_settings.py
|
||||
5
README.md
Normal file
5
README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# alfagok
|
||||
|
||||
Omdat Nederlanders ook [alphaguess](https://alphaguess.com) willen spelen :)
|
||||
|
||||
My own implementation of an alphaguess like game with custom word lists, tailored to be used with a Dutch source.
|
||||
72
pyproject.toml
Normal file
72
pyproject.toml
Normal file
@@ -0,0 +1,72 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=61.0"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "webhaak"
|
||||
version = "0.6.0-pre"
|
||||
authors = [
|
||||
{name = "Michiel Scholten", email = "michiel@diginaut.net"},
|
||||
]
|
||||
description= "Simple webhook service to update and deploy sites and do other maintenance and automatic tasks"
|
||||
readme = "README.rst"
|
||||
requires-python = ">=3.8"
|
||||
keywords = ["webhook", "api", "automation", "CI/CD", "Git", "monitoring"]
|
||||
license = {text = "Apache"}
|
||||
classifiers = [
|
||||
"Framework :: FastAPI",
|
||||
"Programming Language :: Python :: 3",
|
||||
"License :: OSI Approved :: Apache Software License",
|
||||
]
|
||||
dependencies = [
|
||||
"fastapi[all]",
|
||||
"pydantic>2.0",
|
||||
"strictyaml",
|
||||
"gitpython",
|
||||
"rq"
|
||||
]
|
||||
# dynamic = ["version"]
|
||||
|
||||
[project.scripts]
|
||||
my-script = "webhaak:app"
|
||||
|
||||
[project.urls]
|
||||
"Homepage" = "https://github.com/aquatix/webhaak"
|
||||
"Bug Tracker" = "https://github.com/aquatix/webhaak/issues"
|
||||
|
||||
[tool.ruff]
|
||||
exclude = [
|
||||
".git",
|
||||
"__pycache__",
|
||||
"docs/source/conf.py",
|
||||
"build",
|
||||
"dist",
|
||||
"example_config/gunicorn_webhaak_conf.py",
|
||||
"example_config/rq_settings.example.py",
|
||||
"example_config/settings.py",
|
||||
]
|
||||
line-length = 120
|
||||
|
||||
[tool.ruff.format]
|
||||
# Use single quotes for non-triple-quoted strings.
|
||||
quote-style = "single"
|
||||
|
||||
[tool.ruff.lint]
|
||||
ignore = ["D203", "D213"]
|
||||
select = [
|
||||
"C9",
|
||||
"D",
|
||||
"E",
|
||||
"F",
|
||||
"I",
|
||||
"W",
|
||||
]
|
||||
|
||||
[tool.ruff.lint.isort]
|
||||
section-order = ["future", "standard-library","third-party", "first-party", "testing", "local-folder"]
|
||||
|
||||
[tool.ruff.lint.isort.sections]
|
||||
testing = ["tests"]
|
||||
|
||||
[tool.ruff.lint.mccabe]
|
||||
max-complexity = 10
|
||||
2
requirements.in
Normal file
2
requirements.in
Normal file
@@ -0,0 +1,2 @@
|
||||
fastapi[standard]
|
||||
pydantic-settings
|
||||
94
requirements.txt
Normal file
94
requirements.txt
Normal file
@@ -0,0 +1,94 @@
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile requirements.in
|
||||
annotated-types==0.7.0
|
||||
# via pydantic
|
||||
anyio==4.6.2.post1
|
||||
# via
|
||||
# httpx
|
||||
# starlette
|
||||
# watchfiles
|
||||
certifi==2024.8.30
|
||||
# via
|
||||
# httpcore
|
||||
# httpx
|
||||
click==8.1.7
|
||||
# via
|
||||
# typer
|
||||
# uvicorn
|
||||
dnspython==2.7.0
|
||||
# via email-validator
|
||||
email-validator==2.2.0
|
||||
# via fastapi
|
||||
fastapi==0.115.4
|
||||
# via -r requirements.in
|
||||
fastapi-cli==0.0.5
|
||||
# via fastapi
|
||||
h11==0.14.0
|
||||
# via
|
||||
# httpcore
|
||||
# uvicorn
|
||||
httpcore==1.0.6
|
||||
# via httpx
|
||||
httptools==0.6.4
|
||||
# via uvicorn
|
||||
httpx==0.27.2
|
||||
# via fastapi
|
||||
idna==3.10
|
||||
# via
|
||||
# anyio
|
||||
# email-validator
|
||||
# httpx
|
||||
jinja2==3.1.4
|
||||
# via fastapi
|
||||
markdown-it-py==3.0.0
|
||||
# via rich
|
||||
markupsafe==3.0.2
|
||||
# via jinja2
|
||||
mdurl==0.1.2
|
||||
# via markdown-it-py
|
||||
pydantic==2.9.2
|
||||
# via
|
||||
# fastapi
|
||||
# pydantic-settings
|
||||
pydantic-core==2.23.4
|
||||
# via pydantic
|
||||
pydantic-settings==2.6.1
|
||||
# via -r requirements.in
|
||||
pygments==2.18.0
|
||||
# via rich
|
||||
python-dotenv==1.0.1
|
||||
# via
|
||||
# pydantic-settings
|
||||
# uvicorn
|
||||
python-multipart==0.0.17
|
||||
# via fastapi
|
||||
pyyaml==6.0.2
|
||||
# via uvicorn
|
||||
rich==13.9.4
|
||||
# via typer
|
||||
shellingham==1.5.4
|
||||
# via typer
|
||||
sniffio==1.3.1
|
||||
# via
|
||||
# anyio
|
||||
# httpx
|
||||
starlette==0.41.2
|
||||
# via fastapi
|
||||
typer==0.12.5
|
||||
# via fastapi-cli
|
||||
typing-extensions==4.12.2
|
||||
# via
|
||||
# fastapi
|
||||
# pydantic
|
||||
# pydantic-core
|
||||
# typer
|
||||
uvicorn==0.32.0
|
||||
# via
|
||||
# fastapi
|
||||
# fastapi-cli
|
||||
uvloop==0.21.0
|
||||
# via uvicorn
|
||||
watchfiles==0.24.0
|
||||
# via uvicorn
|
||||
websockets==13.1
|
||||
# via uvicorn
|
||||
1
src/alfagok/__init__.py
Normal file
1
src/alfagok/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""alfagok package."""
|
||||
23
src/alfagok/main.py
Normal file
23
src/alfagok/main.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from typing import Union
|
||||
|
||||
from fastapi import FastAPI
|
||||
from pydantic_settings import BaseSettings
|
||||
from pydantic import FilePath
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
word_list: FilePath
|
||||
|
||||
|
||||
app = FastAPI()
|
||||
settings = Settings()
|
||||
|
||||
|
||||
@app.get("/")
|
||||
def read_root():
|
||||
return {"Hello": "World"}
|
||||
|
||||
|
||||
@app.get("/items/{item_id}")
|
||||
def read_item(item_id: int, q: Union[str, None] = None):
|
||||
return {"item_id": item_id, "q": q}
|
||||
21
tox.ini
Normal file
21
tox.ini
Normal file
@@ -0,0 +1,21 @@
|
||||
[flake8]
|
||||
ignore = D203, W503
|
||||
exclude =
|
||||
.git,
|
||||
__pycache__,
|
||||
docs/source/conf.py,
|
||||
build,
|
||||
dist,
|
||||
example_config/gunicorn_webhaak_conf.py,
|
||||
example_config/rq_settings.example.py,
|
||||
example_config/settings.py,
|
||||
max-line-length = 120
|
||||
max-complexity = 10
|
||||
|
||||
[pycodestyle]
|
||||
max_line_length = 120
|
||||
ignore = E501, W503
|
||||
|
||||
[isort]
|
||||
line_length = 120
|
||||
multi_line_output = 3
|
||||
36
wordlist/create_list.py
Normal file
36
wordlist/create_list.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import random
|
||||
|
||||
MIN_LENGTH = 5
|
||||
MAX_LENGTH = 10
|
||||
|
||||
NUMBER_DAYS = 5 * 365
|
||||
|
||||
with open('basiswoorden-gekeurd.txt', 'r', encoding='utf-8') as wordfile:
|
||||
all_words = wordfile.readlines()
|
||||
print(f'original list contains {len(all_words)} words')
|
||||
|
||||
result_list = []
|
||||
for word in all_words:
|
||||
word = word.strip()
|
||||
if word.isalpha() and word.lower() == word and len(word) > MIN_LENGTH and len(word) <= MAX_LENGTH:
|
||||
result_list.append(f'{word}\n')
|
||||
|
||||
# print(result_list)
|
||||
print(f'words filtered: {len(result_list)} with length > {MIN_LENGTH} and <= {MAX_LENGTH}')
|
||||
|
||||
with open('filtered.txt', 'w', encoding='utf-8') as f:
|
||||
f.writelines(result_list)
|
||||
|
||||
selection_list = []
|
||||
|
||||
# Randomly select words for each day
|
||||
while len(selection_list) < NUMBER_DAYS:
|
||||
# Use index - 1 because lists start at index 0
|
||||
word_index = random.randrange(0, len(result_list) - 1)
|
||||
selection_list.append(result_list[word_index])
|
||||
|
||||
# Save the result
|
||||
with open('word_of_the_day.txt', 'w', encoding='utf-8') as f:
|
||||
f.writelines(selection_list)
|
||||
|
||||
print(f'done writing {len(selection_list)} random words, enjoy!')
|
||||
Reference in New Issue
Block a user