diff --git a/.isort.cfg b/.isort.cfg index 28f4ec7..536022e 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -10,4 +10,5 @@ force_single_line = False import_heading_stdlib = Standard Library import_heading_thirdparty = Third Party import_heading_firstparty = Project +import_heading_localfolder = Local known_third_party = starlette,fastapi,inquirer \ No newline at end of file diff --git a/hyperglass/cli/commands.py b/hyperglass/cli/commands.py index a04136e..9c60838 100644 --- a/hyperglass/cli/commands.py +++ b/hyperglass/cli/commands.py @@ -12,6 +12,7 @@ from click import group, option, confirm, help_option # Project from hyperglass.util import cpu_count +# Local from .echo import error, label, success, cmd_help from .util import build_ui from .static import LABEL, CLI_HELP, E diff --git a/hyperglass/execution/drivers/__init__.py b/hyperglass/execution/drivers/__init__.py index fd3bb6f..d83c8cc 100644 --- a/hyperglass/execution/drivers/__init__.py +++ b/hyperglass/execution/drivers/__init__.py @@ -1,5 +1,6 @@ """Individual transport driver classes & subclasses.""" +# Local from .agent import AgentConnection from .ssh_netmiko import NetmikoConnection from .ssh_scrapli import ScrapliConnection diff --git a/hyperglass/execution/drivers/_common.py b/hyperglass/execution/drivers/_common.py index 68a6af0..c37739a 100644 --- a/hyperglass/execution/drivers/_common.py +++ b/hyperglass/execution/drivers/_common.py @@ -10,6 +10,7 @@ from hyperglass.parsing.nos import scrape_parsers, structured_parsers from hyperglass.parsing.common import parsers from hyperglass.models.config.devices import Device +# Local from ._construct import Construct diff --git a/hyperglass/execution/drivers/agent.py b/hyperglass/execution/drivers/agent.py index d1d97d8..5adc1de 100644 --- a/hyperglass/execution/drivers/agent.py +++ b/hyperglass/execution/drivers/agent.py @@ -20,6 +20,7 @@ from hyperglass.encode import jwt_decode, jwt_encode from hyperglass.exceptions import RestError, ResponseEmpty from hyperglass.configuration import params +# Local from ._common import Connection diff --git a/hyperglass/execution/drivers/ssh.py b/hyperglass/execution/drivers/ssh.py index ce9713b..02a975c 100644 --- a/hyperglass/execution/drivers/ssh.py +++ b/hyperglass/execution/drivers/ssh.py @@ -9,6 +9,7 @@ from hyperglass.exceptions import ScrapeError from hyperglass.configuration import params from hyperglass.compat._sshtunnel import BaseSSHTunnelForwarderError, open_tunnel +# Local from ._common import Connection diff --git a/hyperglass/execution/drivers/ssh_netmiko.py b/hyperglass/execution/drivers/ssh_netmiko.py index efb49ec..71ac1f7 100644 --- a/hyperglass/execution/drivers/ssh_netmiko.py +++ b/hyperglass/execution/drivers/ssh_netmiko.py @@ -19,6 +19,7 @@ from hyperglass.log import log from hyperglass.exceptions import AuthError, ScrapeError, DeviceTimeout from hyperglass.configuration import params +# Local from .ssh import SSHConnection netmiko_nos_globals = { diff --git a/hyperglass/execution/drivers/ssh_scrapli.py b/hyperglass/execution/drivers/ssh_scrapli.py index 7b21108..077b719 100644 --- a/hyperglass/execution/drivers/ssh_scrapli.py +++ b/hyperglass/execution/drivers/ssh_scrapli.py @@ -33,6 +33,7 @@ from hyperglass.exceptions import ( ) from hyperglass.configuration import params +# Local from .ssh import SSHConnection SCRAPLI_DRIVER_MAP = { diff --git a/hyperglass/execution/main.py b/hyperglass/execution/main.py index 4d9cb6a..922f1d7 100644 --- a/hyperglass/execution/main.py +++ b/hyperglass/execution/main.py @@ -17,6 +17,7 @@ from hyperglass.exceptions import DeviceTimeout, ResponseEmpty from hyperglass.models.api import Query from hyperglass.configuration import params +# Local from .drivers import AgentConnection, NetmikoConnection, ScrapliConnection DRIVER_MAP = { diff --git a/hyperglass/external/__init__.py b/hyperglass/external/__init__.py index 9ffc3bd..358b0d8 100644 --- a/hyperglass/external/__init__.py +++ b/hyperglass/external/__init__.py @@ -1,4 +1,5 @@ """Functions & handlers for external data.""" +# Local from .ripestat import RIPEStat # noqa: F401 from .webhooks import Webhook # noqa: F401 diff --git a/hyperglass/models/__init__.py b/hyperglass/models/__init__.py index 729ad1d..98929cf 100644 --- a/hyperglass/models/__init__.py +++ b/hyperglass/models/__init__.py @@ -1,3 +1,4 @@ """All Data Models used by hyperglass.""" +# Local from .main import HyperglassModel, HyperglassModelExtra diff --git a/hyperglass/models/api/__init__.py b/hyperglass/models/api/__init__.py index 4f2eaf1..ffe11f6 100644 --- a/hyperglass/models/api/__init__.py +++ b/hyperglass/models/api/__init__.py @@ -1,4 +1,5 @@ """Query & Response Validation Models.""" +# Local from .query import Query from .response import ( QueryError, diff --git a/hyperglass/models/api/query.py b/hyperglass/models/api/query.py index 197ea3f..6b7bf5c 100644 --- a/hyperglass/models/api/query.py +++ b/hyperglass/models/api/query.py @@ -13,6 +13,7 @@ from pydantic import BaseModel, StrictStr, constr, validator from hyperglass.exceptions import InputInvalid from hyperglass.configuration import params, devices +# Local from .types import SupportedQuery from .validators import ( validate_ip, diff --git a/hyperglass/models/commands/__init__.py b/hyperglass/models/commands/__init__.py index cb80687..a5d5e34 100644 --- a/hyperglass/models/commands/__init__.py +++ b/hyperglass/models/commands/__init__.py @@ -1,5 +1,6 @@ """Validate command configuration variables.""" +# Local from .vyos import VyosCommands from ..main import HyperglassModelExtra from .arista import AristaCommands diff --git a/hyperglass/models/commands/_mikrotik_base.py b/hyperglass/models/commands/_mikrotik_base.py index af1b5fe..86ac480 100644 --- a/hyperglass/models/commands/_mikrotik_base.py +++ b/hyperglass/models/commands/_mikrotik_base.py @@ -3,6 +3,7 @@ # Third Party from pydantic import StrictStr +# Local from .common import CommandSet, CommandGroup diff --git a/hyperglass/models/commands/arista.py b/hyperglass/models/commands/arista.py index 796e189..dbc858c 100644 --- a/hyperglass/models/commands/arista.py +++ b/hyperglass/models/commands/arista.py @@ -3,6 +3,7 @@ # Third Party from pydantic import StrictStr +# Local from .common import CommandSet, CommandGroup diff --git a/hyperglass/models/commands/cisco_ios.py b/hyperglass/models/commands/cisco_ios.py index 6a76cd3..affd3e5 100644 --- a/hyperglass/models/commands/cisco_ios.py +++ b/hyperglass/models/commands/cisco_ios.py @@ -3,6 +3,7 @@ # Third Party from pydantic import StrictStr +# Local from .common import CommandSet, CommandGroup diff --git a/hyperglass/models/commands/cisco_nxos.py b/hyperglass/models/commands/cisco_nxos.py index 7cfa031..58e61fc 100644 --- a/hyperglass/models/commands/cisco_nxos.py +++ b/hyperglass/models/commands/cisco_nxos.py @@ -3,6 +3,7 @@ # Third Party from pydantic import StrictStr +# Local from .common import CommandSet, CommandGroup diff --git a/hyperglass/models/commands/cisco_xr.py b/hyperglass/models/commands/cisco_xr.py index dbad4af..01ed2a5 100644 --- a/hyperglass/models/commands/cisco_xr.py +++ b/hyperglass/models/commands/cisco_xr.py @@ -3,6 +3,7 @@ # Third Party from pydantic import StrictStr +# Local from .common import CommandSet, CommandGroup diff --git a/hyperglass/models/commands/common.py b/hyperglass/models/commands/common.py index 1b55147..347efd2 100644 --- a/hyperglass/models/commands/common.py +++ b/hyperglass/models/commands/common.py @@ -3,6 +3,7 @@ # Third Party from pydantic import StrictStr +# Local from ..main import HyperglassModel, HyperglassModelExtra diff --git a/hyperglass/models/commands/huawei.py b/hyperglass/models/commands/huawei.py index 883ba46..eea35d1 100644 --- a/hyperglass/models/commands/huawei.py +++ b/hyperglass/models/commands/huawei.py @@ -3,6 +3,7 @@ # Third Party from pydantic import StrictStr +# Local from .common import CommandSet, CommandGroup diff --git a/hyperglass/models/commands/juniper.py b/hyperglass/models/commands/juniper.py index dbea990..c761f4b 100644 --- a/hyperglass/models/commands/juniper.py +++ b/hyperglass/models/commands/juniper.py @@ -3,6 +3,7 @@ # Third Party from pydantic import StrictStr +# Local from .common import CommandSet, CommandGroup diff --git a/hyperglass/models/commands/mikrotik_routeros.py b/hyperglass/models/commands/mikrotik_routeros.py index ac48426..ab986f6 100644 --- a/hyperglass/models/commands/mikrotik_routeros.py +++ b/hyperglass/models/commands/mikrotik_routeros.py @@ -1,4 +1,5 @@ """Mikrotik RouterOS Commands Model.""" +# Local from ._mikrotik_base import MikrotikCommands diff --git a/hyperglass/models/commands/mikrotik_switchos.py b/hyperglass/models/commands/mikrotik_switchos.py index 6e19268..4e18c31 100644 --- a/hyperglass/models/commands/mikrotik_switchos.py +++ b/hyperglass/models/commands/mikrotik_switchos.py @@ -1,4 +1,5 @@ """Mikrotik SwitchOS Commands Model.""" +# Local from ._mikrotik_base import MikrotikCommands diff --git a/hyperglass/models/commands/vyos.py b/hyperglass/models/commands/vyos.py index f057332..fff5dd9 100644 --- a/hyperglass/models/commands/vyos.py +++ b/hyperglass/models/commands/vyos.py @@ -3,6 +3,7 @@ # Third Party from pydantic import StrictStr +# Local from .common import CommandSet, CommandGroup diff --git a/hyperglass/models/webhook.py b/hyperglass/models/webhook.py index a360d10..a61e273 100644 --- a/hyperglass/models/webhook.py +++ b/hyperglass/models/webhook.py @@ -10,6 +10,7 @@ from pydantic import StrictStr, root_validator # Project from hyperglass.log import log +# Local from .main import HyperglassModel, HyperglassModelExtra _WEBHOOK_TITLE = "hyperglass received a valid query with the following data" diff --git a/hyperglass/parsing/nos.py b/hyperglass/parsing/nos.py index e661af5..1da7e2b 100644 --- a/hyperglass/parsing/nos.py +++ b/hyperglass/parsing/nos.py @@ -1,5 +1,6 @@ """Map NOS and Commands to Parsing Functions.""" +# Local from .juniper import parse_juniper from .mikrotik import parse_mikrotik diff --git a/hyperglass/util/__init__.py b/hyperglass/util/__init__.py index b93165b..36e2355 100644 --- a/hyperglass/util/__init__.py +++ b/hyperglass/util/__init__.py @@ -682,7 +682,7 @@ async def build_frontend( # noqa: C901 return True -def set_app_path(required=False): +def set_app_path(required: bool = False) -> Path: """Find app directory and set value to environment variable.""" # Standard Library @@ -711,15 +711,15 @@ def set_app_path(required=False): No configuration directories were determined to both exist and be readable by hyperglass. hyperglass is running as user '{un}' (UID '{uid}'), and tried to access the following directories: - {dir}""".format( +{dir}""".format( un=getuser(), uid=os.getuid(), - dir="\n".join([" - " + str(p) for p in config_paths]), + dir="\n".join(["\t - " + str(p) for p in config_paths]), ) ) os.environ["hyperglass_directory"] = str(matched_path) - return True + return matched_path def format_listen_address(listen_address: Union[IPv4Address, IPv6Address, str]) -> str: