Skip to content

Commit

Permalink
switch to poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
simonsmh authored Jun 11, 2024
1 parent e3cd881 commit 6c0d619
Show file tree
Hide file tree
Showing 11 changed files with 1,501 additions and 1,063 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ data
*.db-wal
*.log*

dist/
.tmp/
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM python:3.12
FROM python:3.12-slim

WORKDIR /usr/src/app
COPY pyproject.toml poetry.lock ./
RUN pip install poetry && poetry install --only main --no-root --no-directory --no-cache
COPY . .
RUN pip install --no-cache-dir -r requirements.txt
RUN poetry install --only main
ENV PORT=9000 \
TOKEN=""
ENTRYPOINT ["python"]
CMD ["main.py"]
ENTRYPOINT ["poetry", "run", "python", "-m", "biliparser"]
26 changes: 0 additions & 26 deletions Pipfile

This file was deleted.

1,013 changes: 0 additions & 1,013 deletions Pipfile.lock

This file was deleted.

File renamed without changes.
9 changes: 4 additions & 5 deletions main.py → biliparser/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@
filters,
)

from biliparser import biliparser
from biliparser.utils import (
from . import biliparser
from .database import db_close, db_init, file_cache
from .utils import (
LOCAL_MODE,
compress,
escape_markdown,
headers,
logger,
referer_url,
)
from database import db_close, db_init, file_cache

BILIBILI_URL_REGEX = r"(?i)(?:https?://)?[\w\.]*?(?:bilibili(?:bb)?\.com|(?:b23(?:bb)?|acg)\.tv)\S+|BV\w{10}"
BILIBILI_SHARE_URL_REGEX = r"(?i)【.*】 https://[\w\.]*?(?:bilibili\.com|b23\.tv)\S+"
Expand Down Expand Up @@ -672,6 +672,7 @@ async def post_shutdown(application: Application):

def add_handler(application: Application):
application.add_handler(CommandHandler("start", start, block=False))
application.add_handler(CommandHandler("file", fetch, block=False))
application.add_handler(
MessageHandler(
filters.Entity(MessageEntity.URL)
Expand All @@ -683,8 +684,6 @@ def add_handler(application: Application):
)
)
application.add_handler(InlineQueryHandler(inlineparse, block=False))
application.add_handler(CommandHandler("parse", parse, block=False))
application.add_handler(CommandHandler("file", fetch, block=False))
application.add_error_handler(error_handler)


Expand Down
4 changes: 2 additions & 2 deletions database.py → biliparser/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from tortoise import Tortoise, fields
from tortoise.models import Model

from biliparser.utils import logger
from .utils import logger


class file_cache(Model):
Expand All @@ -23,7 +23,7 @@ async def db_init() -> None:
logger.info(f"redis_url: {redis_url}")
await Tortoise.init(
db_url=db_url,
modules={"models": ["database"]},
modules={"models": ["biliparser.database"]},
use_tz=True,
)
await Tortoise.generate_schemas()
Expand Down
1 change: 0 additions & 1 deletion biliparser/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from loguru import logger
from PIL import Image
from tortoise.exceptions import IntegrityError

logger.remove()
logger.add(sys.stdout, backtrace=True, diagnose=True)
Expand Down
1,459 changes: 1,459 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[tool.poetry]
name = "telegram-bili-feed-helper"
version = "0.1.0"
description = ""
authors = ["simonsmh"]
license = "GPLv3"
readme = "README.md"
packages = [{ include = "biliparser" }]

[tool.poetry.dependencies]
python = "^3.12"
aiomysql = "^0.2.0"
asyncpg = "^0.29.0"
beautifulsoup4 = "^4.12.3"
httpx = {extras = ["http2"], version = "^0.27.0"}
loguru = "^0.7.2"
lxml = "^5.2.2"
pillow = "^10.3.0"
python-telegram-bot = {extras = ["all"], version = "^21.3"}
redis = "^5.0.5"
telegraph = {extras = ["aio"], version = "^2.2.0"}
tortoise-orm = {extras = ["accel"], version = "^0.21.3"}

[tool.poetry.group.dev.dependencies]
pytest = "^8.2.2"
pytest-asyncio = "^0.23.7"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
12 changes: 0 additions & 12 deletions requirements.txt

This file was deleted.

0 comments on commit 6c0d619

Please sign in to comment.