Use black with -l 120 param.

This commit is contained in:
grossmj committed 2021-04-13 18:46:50 +09:30
1 parent f928738bd5
commit c021e21309
194 files changed
+6034 -4564

No files matched your search

+1
View File
@@ -15,4 +15,5 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from .authentication import AuthService
auth_service = AuthService()
+2 -7
View File
@@ -26,6 +26,7 @@ from gns3server.config import Config
from pydantic import ValidationError
import logging
log = logging.getLogger(__name__)
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
@@ -34,7 +35,6 @@ DEFAULT_JWT_SECRET_KEY = "efd08eccec3bd0a1be2e086670e5efa90969c68d07e072d7354a76
class AuthService:
def hash_password(self, password: str) -> str:
return pwd_context.hash(password)
@@ -43,12 +43,7 @@ class AuthService:
return pwd_context.verify(password, hashed_password)
def create_access_token(
self,
username,
secret_key: str = None,
expires_in: int = 0
) -> str:
def create_access_token(self, username, secret_key: str = None, expires_in: int = 0) -> str:
if not expires_in:
expires_in = Config.instance().settings.Controller.jwt_access_token_expire_minutes
+7 -8
View File
@@ -26,12 +26,11 @@ from gns3server.controller import Controller
from gns3server.controller.controller_error import (
ControllerBadRequestError,
ControllerNotFoundError,
ControllerForbiddenError
ControllerForbiddenError,
)
class ComputesService:
def __init__(self, computes_repo: ComputesRepository):
self._computes_repo = computes_repo
@@ -47,9 +46,11 @@ class ComputesService:
if await self._computes_repo.get_compute(compute_create.compute_id):
raise ControllerBadRequestError(f"Compute '{compute_create.compute_id}' is already registered")
db_compute = await self._computes_repo.create_compute(compute_create)
await self._controller.add_compute(compute_id=str(db_compute.compute_id),
connect=False,
**compute_create.dict(exclude_unset=True, exclude={"compute_id"}))
await self._controller.add_compute(
compute_id=str(db_compute.compute_id),
connect=False,
**compute_create.dict(exclude_unset=True, exclude={"compute_id"}),
)
self._controller.notification.controller_emit("compute.created", db_compute.asjson())
return db_compute
@@ -61,9 +62,7 @@ class ComputesService:
return db_compute
async def update_compute(
self,
compute_id: Union[str, UUID],
compute_update: schemas.ComputeUpdate
self, compute_id: Union[str, UUID], compute_update: schemas.ComputeUpdate
) -> models.Compute:
compute = self._controller.get_compute(str(compute_id))
+10 -11
View File
@@ -27,7 +27,7 @@ from gns3server.controller import Controller
from gns3server.controller.controller_error import (
ControllerBadRequestError,
ControllerNotFoundError,
ControllerForbiddenError
ControllerForbiddenError,
)
TEMPLATE_TYPE_TO_SHEMA = {
@@ -40,7 +40,7 @@ TEMPLATE_TYPE_TO_SHEMA = {
"virtualbox": schemas.VirtualBoxTemplate,
"vmware": schemas.VMwareTemplate,
"iou": schemas.IOUTemplate,
"qemu": schemas.QemuTemplate
"qemu": schemas.QemuTemplate,
}
DYNAMIPS_PLATFORM_TO_SHEMA = {
@@ -50,7 +50,7 @@ DYNAMIPS_PLATFORM_TO_SHEMA = {
"c3600": schemas.C3600DynamipsTemplate,
"c2691": schemas.C2691DynamipsTemplate,
"c2600": schemas.C2600DynamipsTemplate,
"c1700": schemas.C1700DynamipsTemplate
"c1700": schemas.C1700DynamipsTemplate,
}
# built-in templates have their compute_id set to None to tell clients to select a compute
@@ -63,7 +63,7 @@ BUILTIN_TEMPLATES = [
"category": "guest",
"symbol": ":/symbols/cloud.svg",
"compute_id": None,
"builtin": True
"builtin": True,
},
{
"template_id": uuid.uuid3(uuid.NAMESPACE_DNS, "nat"),
@@ -73,7 +73,7 @@ BUILTIN_TEMPLATES = [
"category": "guest",
"symbol": ":/symbols/cloud.svg",
"compute_id": None,
"builtin": True
"builtin": True,
},
{
"template_id": uuid.uuid3(uuid.NAMESPACE_DNS, "vpcs"),
@@ -84,7 +84,7 @@ BUILTIN_TEMPLATES = [
"symbol": ":/symbols/vpcs_guest.svg",
"base_script_file": "vpcs_base_config.txt",
"compute_id": None,
"builtin": True
"builtin": True,
},
{
"template_id": uuid.uuid3(uuid.NAMESPACE_DNS, "ethernet_switch"),
@@ -95,7 +95,7 @@ BUILTIN_TEMPLATES = [
"category": "switch",
"symbol": ":/symbols/ethernet_switch.svg",
"compute_id": None,
"builtin": True
"builtin": True,
},
{
"template_id": uuid.uuid3(uuid.NAMESPACE_DNS, "ethernet_hub"),
@@ -105,7 +105,7 @@ BUILTIN_TEMPLATES = [
"category": "switch",
"symbol": ":/symbols/hub.svg",
"compute_id": None,
"builtin": True
"builtin": True,
},
{
"template_id": uuid.uuid3(uuid.NAMESPACE_DNS, "frame_relay_switch"),
@@ -115,7 +115,7 @@ BUILTIN_TEMPLATES = [
"category": "switch",
"symbol": ":/symbols/frame_relay_switch.svg",
"compute_id": None,
"builtin": True
"builtin": True,
},
{
"template_id": uuid.uuid3(uuid.NAMESPACE_DNS, "atm_switch"),
@@ -125,13 +125,12 @@ BUILTIN_TEMPLATES = [
"category": "switch",
"symbol": ":/symbols/atm_switch.svg",
"compute_id": None,
"builtin": True
"builtin": True,
},
]
class TemplatesService:
def __init__(self, templates_repo: TemplatesRepository):
self._templates_repo = templates_repo