style: sort imports in api and utils modules

This commit is contained in:
Mark Paronyan committed 2026-10-02 12:43:26 +03:00
1 parent 4ebc941951
commit 634189d443
64 files changed
+247 -250

No files matched your search

+6 -6
View File
@@ -16,14 +16,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
import re
import shlex
import textwrap
import posixpath
import socket
import errno
import hashlib
import posixpath
import re
import shlex
import socket
import sys
import textwrap
def force_unix_path(path):
+2 -2
View File
@@ -15,10 +15,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from gns3server.controller.controller_error import ControllerError
import logging
from gns3server.controller.controller_error import ControllerError
log = logging.getLogger(__name__)
# IOU draws from the lower half: uBridge's iol_bridge uses application_id + 512
+4 -4
View File
@@ -15,12 +15,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import functools
import asyncio
import sys
import os
import threading
import functools
import inspect
import os
import sys
import threading
async def wait_run_in_executor(func, *args, **kwargs):
+4 -3
View File
@@ -22,16 +22,17 @@ Derived directly from zipfile.py and the zipstream project
https://github.com/allanlei/python-zipstream
"""
import asyncio
import os
import sys
import stat
import struct
import sys
import time
import zipfile
import asyncio
import aiofiles
from concurrent import futures
import aiofiles
structCentralDir = "<4s4B4HL2L5H2L"
structEndArchive64 = "<4sQ2H2L4Q"
structEndArchive = b"<4s4H2LH"
+5 -5
View File
@@ -16,24 +16,24 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
import asyncio
import inspect
import io
import sys
from prompt_toolkit import prompt
from prompt_toolkit.history import InMemoryHistory
from prompt_toolkit.contrib.completers import WordCompleter
from prompt_toolkit.enums import DEFAULT_BUFFER
from prompt_toolkit.eventloop.base import EventLoop
from prompt_toolkit.history import InMemoryHistory
from prompt_toolkit.input import StdinInput
from prompt_toolkit.interface import CommandLineInterface
from prompt_toolkit.layout.screen import Size
from prompt_toolkit.shortcuts import create_prompt_application, create_asyncio_eventloop
from prompt_toolkit.shortcuts import create_asyncio_eventloop, create_prompt_application
from prompt_toolkit.terminal.vt100_output import Vt100_Output
from prompt_toolkit.input import StdinInput
from gns3server.utils.asyncio.telnet_server import AsyncioTelnetServer, TelnetConnection
from gns3server.utils.asyncio.input_stream import InputStream
from gns3server.utils.asyncio.telnet_server import AsyncioTelnetServer, TelnetConnection
class EmbedShell:
+2 -3
View File
@@ -5,11 +5,10 @@ Parser for VT100 input stream.
# Copied from prompt_toolkit/terminal/vt100_input.py due to dependency on termios (which is not available on Windows)
import re
import six
from prompt_toolkit.keys import Keys
from prompt_toolkit.key_binding.input_processor import KeyPress
from prompt_toolkit.keys import Keys
# __all__ = (
# 'InputStream',
+1 -1
View File
@@ -15,8 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
import asyncio
import sys
class Pool:
@@ -14,12 +14,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import re
import copy
import asyncio
import asyncio.subprocess
import copy
import logging
import re
log = logging.getLogger(__name__)
+1 -1
View File
@@ -17,8 +17,8 @@
import asyncio
from gns3server.utils.asyncio import wait_for_file_creation
from gns3server.compute.error import NodeError
from gns3server.utils.asyncio import wait_for_file_creation
"""
This module handle connection to unix socket
+2 -1
View File
@@ -14,9 +14,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import psutil
import time
import psutil
class CpuPercent:
"""
+2 -1
View File
@@ -19,9 +19,10 @@ Encryption utilities for sensitive data like API keys.
Uses Fernet symmetric encryption.
"""
import os
import logging
import os
from typing import Optional
from cryptography.fernet import Fernet
log = logging.getLogger(__name__)
+2 -3
View File
@@ -15,11 +15,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import zlib
import asyncio
import os
import logging
import os
import zlib
log = logging.getLogger(__name__)
+3 -3
View File
@@ -15,11 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import aiohttp
from pydantic import SecretStr
import logging
import socket
import logging
import aiohttp
from pydantic import SecretStr
log = logging.getLogger(__name__)
+10 -9
View File
@@ -14,30 +14,31 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import hashlib
import stat
import aiofiles
import asyncio
import hashlib
import os
import stat
import tempfile
from gns3server.utils.image_inventory import fingerprint, stat_fingerprint, image_lock, publish_image, contained_path
import aiofiles
from gns3server.utils.image_inventory import contained_path, fingerprint, image_lock, publish_image, stat_fingerprint
try:
import importlib_resources
except ImportError:
from importlib import resources as importlib_resources
from typing import List, AsyncGenerator
from ..config import Config
from . import force_unix_path
import logging
from io import DEFAULT_BUFFER_SIZE
from typing import AsyncGenerator, List
import gns3server.db.models as models
from gns3server.db.repositories.images import ImagesRepository
from gns3server.utils.asyncio import wait_run_in_executor
import logging
from ..config import Config
from . import force_unix_path
log = logging.getLogger(__name__)
+3 -2
View File
@@ -16,9 +16,10 @@
import os
import sys
import socket
import struct
import sys
import psutil
from gns3server.compute.compute_error import ComputeError
@@ -94,8 +95,8 @@ def get_windows_interfaces():
:returns: list of windows interfaces
"""
import win32com.client
import pywintypes
import win32com.client
interfaces = []
try:
+2 -2
View File
@@ -17,14 +17,14 @@
import asyncio
import json
import logging
import time
import psutil
from gns3server.utils.cpu_percent import CpuPercent
from gns3server.utils.path import get_default_project_directory
import logging
log = logging.getLogger(__name__)
+1 -1
View File
@@ -4,7 +4,7 @@ Packet filter parameter validation utilities.
import logging
import subprocess
from typing import Dict, List, Any, Optional
from typing import Any, Dict, List, Optional
log = logging.getLogger(__name__)
+2 -1
View File
@@ -16,9 +16,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
from pathlib import Path
from fastapi import HTTPException, status
from ..config import Config
+1 -1
View File
@@ -15,8 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import re
import io
import re
import struct
from xml.etree.ElementTree import ElementTree, ParseError
-1
View File
@@ -5,7 +5,6 @@
import hashlib
# Display/port allocation range (stable across process restarts)
DISPLAY_RANGE = 10000
DISPLAY_MODULO = 10000
+1 -1
View File
@@ -6,8 +6,8 @@ from ASGI scope dictionaries for logging and debugging purposes.
"""
import logging
from typing import Any, Dict, Optional
from urllib.parse import parse_qs
from typing import Dict, Any, Optional
log = logging.getLogger(__name__)
+3 -3
View File
@@ -7,10 +7,10 @@ Usage:
gns3server-uninstall-ai-features -y
"""
import os
import sys
import subprocess
import argparse
import os
import subprocess
import sys
def _find_base_dir():
-1
View File
@@ -6,7 +6,6 @@
import argparse
import re
UUID_PATTERN = re.compile(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", re.IGNORECASE)
+3 -4
View File
@@ -15,12 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
import os
import ipaddress
import argparse
import ipaddress
import os
import shutil
import sys
from collections import OrderedDict
if sys.platform.startswith("darwin"):
+2 -2
View File
@@ -1,7 +1,7 @@
# NOTE: this patches the standard zipfile module
from . import _zipfile
from zipfile import *
from . import _zipfile
from ._zipfile import (
ZIP_ZSTANDARD,
ZSTANDARD_VERSION,
+3 -2
View File
@@ -1,8 +1,9 @@
import zipfile as _zipfile_module
import zstandard as zstd
import inspect
import zipfile as _zipfile_module
from typing import Any
import zstandard as zstd
from ._patcher import patch
zipfile: Any = _zipfile_module