From 411c584480f32fc38d508a87a52b43e3008aeead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Tue, 15 Mar 2022 16:25:07 +0000 Subject: [PATCH] relative imports --- api/kiwi_vpn_api/db/create_db.py | 5 ++--- api/kiwi_vpn_api/db/model.py | 3 ++- api/kiwi_vpn_api/main.py | 4 ++-- api/kiwi_vpn_api/routers/auth.py | 7 ++++--- api/kiwi_vpn_api/routers/user.py | 7 ++++--- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/api/kiwi_vpn_api/db/create_db.py b/api/kiwi_vpn_api/db/create_db.py index c572ee8..db01ab9 100755 --- a/api/kiwi_vpn_api/db/create_db.py +++ b/api/kiwi_vpn_api/db/create_db.py @@ -1,8 +1,7 @@ #!/usr/bin/env python3 -from kiwi_vpn_api.config import CRYPT_CONTEXT, DB -from kiwi_vpn_api.db.model import (Certificate, DistinguishedName, User, - UserCapability) +from ..config import CRYPT_CONTEXT, DB +from .model import Certificate, DistinguishedName, User, UserCapability def main(): diff --git a/api/kiwi_vpn_api/db/model.py b/api/kiwi_vpn_api/db/model.py index f409729..eae5ba1 100644 --- a/api/kiwi_vpn_api/db/model.py +++ b/api/kiwi_vpn_api/db/model.py @@ -3,10 +3,11 @@ from __future__ import annotations import datetime from typing import Optional -from kiwi_vpn_api.config import CRYPT_CONTEXT, DB from peewee import (BooleanField, CharField, DateTimeField, ForeignKeyField, Model) +from ..config import CRYPT_CONTEXT, DB + class BaseModel(Model): class Meta: diff --git a/api/kiwi_vpn_api/main.py b/api/kiwi_vpn_api/main.py index d56d130..5c540fc 100755 --- a/api/kiwi_vpn_api/main.py +++ b/api/kiwi_vpn_api/main.py @@ -3,8 +3,8 @@ import uvicorn from fastapi import FastAPI -from kiwi_vpn_api.config import PRODUCTION_MODE -from kiwi_vpn_api.routers import auth, user +from .config import PRODUCTION_MODE +from .routers import auth, user api = FastAPI( title="kiwi-vpn API", diff --git a/api/kiwi_vpn_api/routers/auth.py b/api/kiwi_vpn_api/routers/auth.py index ac11009..fafa35b 100644 --- a/api/kiwi_vpn_api/routers/auth.py +++ b/api/kiwi_vpn_api/routers/auth.py @@ -3,11 +3,12 @@ from datetime import datetime, timedelta from fastapi import APIRouter, Depends, HTTPException, status from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm from jose import jwt -from kiwi_vpn_api.config import (ACCESS_TOKEN_EXPIRE_MINUTES, ALGORITHM, - CRYPT_CONTEXT, SECRET_KEY) -from kiwi_vpn_api.db.model import User from pydantic import BaseModel +from ..config import (ACCESS_TOKEN_EXPIRE_MINUTES, ALGORITHM, CRYPT_CONTEXT, + SECRET_KEY) +from ..db.model import User + router = APIRouter(prefix="/auth") SCHEME = OAuth2PasswordBearer( tokenUrl=f".{router.prefix}/token" diff --git a/api/kiwi_vpn_api/routers/user.py b/api/kiwi_vpn_api/routers/user.py index b768788..50db0e7 100644 --- a/api/kiwi_vpn_api/routers/user.py +++ b/api/kiwi_vpn_api/routers/user.py @@ -4,11 +4,12 @@ from typing import Optional from fastapi import APIRouter, Depends, HTTPException, status from jose import JWTError, jwt -from kiwi_vpn_api.routers.auth import SCHEME -from kiwi_vpn_api.config import ALGORITHM, SECRET_KEY -from kiwi_vpn_api.db.model import User as db_User from pydantic import BaseModel +from ..config import ALGORITHM, SECRET_KEY +from ..db.model import User as db_User +from .auth import SCHEME + router = APIRouter(prefix="/user")