Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #84

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
rev: v0.11.4
hooks:
- id: ruff
args:
Expand Down
10 changes: 5 additions & 5 deletions alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

# Import your models and Base
from paste.database import Base

# Import all your models here
from paste.models import Paste
# this is the Alembic Config object
config = context.config

Expand Down Expand Up @@ -46,6 +46,7 @@ def run_migrations_offline() -> None:
with context.begin_transaction():
context.run_migrations()


def run_migrations_online() -> None:
connectable = engine_from_config(
config.get_section(config.config_ini_section, {}),
Expand All @@ -54,14 +55,13 @@ def run_migrations_online() -> None:
)

with connectable.connect() as connection:
context.configure(
connection=connection, target_metadata=target_metadata
)
context.configure(connection=connection, target_metadata=target_metadata)

with context.begin_transaction():
context.run_migrations()


if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
run_migrations_online()
24 changes: 13 additions & 11 deletions alembic/versions/9513acd42747_initial_migration.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
"""Initial migration

Revision ID: 9513acd42747
Revises:
Revises:
Create Date: 2025-02-09 02:54:48.803960

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '9513acd42747'
revision: str = "9513acd42747"
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('pastes',
sa.Column('pasteID', sa.String(length=4), nullable=False),
sa.Column('content', sa.Text(), nullable=True),
sa.Column('extension', sa.String(length=50), nullable=True),
sa.Column('s3_link', sa.String(length=500), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('expiresat', sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint('pasteID')
op.create_table(
"pastes",
sa.Column("pasteID", sa.String(length=4), nullable=False),
sa.Column("content", sa.Text(), nullable=True),
sa.Column("extension", sa.String(length=50), nullable=True),
sa.Column("s3_link", sa.String(length=500), nullable=True),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("expiresat", sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint("pasteID"),
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('pastes')
op.drop_table("pastes")
# ### end Alembic commands ###
4 changes: 3 additions & 1 deletion sdk/example.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from sdk.module import PasteBinSDK


def test_pastebin_sdk():
sdk = PasteBinSDK()

Expand All @@ -23,5 +24,6 @@ def test_pastebin_sdk():
except RuntimeError as e:
print(f"An error occurred: {e}")


if __name__ == "__main__":
test_pastebin_sdk()
test_pastebin_sdk()
14 changes: 6 additions & 8 deletions sdk/sdk/module.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import requests
from typing import Optional, Union
from typing import Union
from pathlib import Path


class PasteBinSDK:
def __init__(self, base_url: str = "https://paste.fosscu.org"):
self.base_url = base_url
Expand All @@ -15,17 +16,14 @@ def create_paste(self, content: Union[str, Path], file_extension: str) -> str:
"""
try:
if isinstance(content, Path):
with open(content, 'r', encoding='utf-8') as f:
with open(content, "r", encoding="utf-8") as f:
content = f.read()

data = {
'content': content,
'extension': file_extension
}
data = {"content": content, "extension": file_extension}
response = requests.post(f"{self.base_url}/api/paste", json=data)
response.raise_for_status()
result = response.json()
return result['uuid']
return result["uuid"]
except requests.RequestException as e:
raise RuntimeError(f"Error creating paste: {str(e)}")

Expand Down Expand Up @@ -65,4 +63,4 @@ def get_languages(self) -> dict:
response.raise_for_status()
return response.json()
except requests.RequestException as e:
raise RuntimeError(f"Error fetching languages: {str(e)}")
raise RuntimeError(f"Error fetching languages: {str(e)}")
Loading