Skip to content

Commit

Permalink
ruff formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
theGowda committed Nov 26, 2024
1 parent 6ecbcc6 commit 01639e9
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
18 changes: 7 additions & 11 deletions apicli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

"""Command line interface for debugging purpouses."""


import logging
import getpass
from argparse import ArgumentParser
Expand All @@ -14,19 +13,16 @@
from librouteros import connect
from librouteros.exceptions import TrapError, FatalError

argParser = ArgumentParser(description='mikrotik api cli interface')
argParser.add_argument(
'host', type=str,
help="host to with to connect. may be fqdn, ipv4 or ipv6 address")
argParser.add_argument('-u', '--user', type=str, required=True, help="username")
argParser.add_argument(
'-p', '--port', type=int, default=8728, help="port to connect to (default 8728)")
argParser = ArgumentParser(description="mikrotik api cli interface")
argParser.add_argument("host", type=str, help="host to with to connect. may be fqdn, ipv4 or ipv6 address")
argParser.add_argument("-u", "--user", type=str, required=True, help="username")
argParser.add_argument("-p", "--port", type=int, default=8728, help="port to connect to (default 8728)")
args = argParser.parse_args()

mainlog = logging.getLogger('librouteros')
mainlog = logging.getLogger("librouteros")
console = logging.StreamHandler(stdout)
mainlog.setLevel(logging.DEBUG)
formatter = logging.Formatter(fmt='%(message)s')
formatter = logging.Formatter(fmt="%(message)s")
console.setFormatter(formatter)
mainlog.addHandler(console)

Expand Down Expand Up @@ -72,5 +68,5 @@ def main():
api.close()


if __name__ == '__main__':
if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion librouteros/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from librouteros.login import (
plain,
token, # noqa: F401 BACK_COMP
async_plain
async_plain,
)
from librouteros.api import Api, AsyncApi

Expand Down
11 changes: 6 additions & 5 deletions librouteros/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,12 @@ def add(self, **kwargs: typing.Any) -> str:

def update(self, **kwargs: typing.Any) -> None:
tuple(
self(
"set",
**kwargs,
)
)
self(
"set",
**kwargs,
)
)


class AsyncApi:
def __init__(self, protocol: AsyncApiProtocol):
Expand Down
3 changes: 2 additions & 1 deletion librouteros/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ def plain(api: typing.Any, username: str, password: str) -> None:
"""Login using post routeros 6.43 authorization method."""
tuple(api("/login", **{"name": username, "password": password}))


async def async_plain(api, username, password):
[response async for response in api("/login", **{"name": username, "password": password})]
[response async for response in api("/login", **{"name": username, "password": password})]
1 change: 1 addition & 0 deletions librouteros/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def readWord(self) -> str:
def close(self) -> None:
self.transport.close()


class AsyncApiProtocol(Encoder, Decoder):
def __init__(self, transport: AsyncSocketTransport, encoding: str, timeout: float):
self.transport = transport
Expand Down
1 change: 1 addition & 0 deletions librouteros/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def Or(left: QueryGen, right: QueryGen, *rest: QueryGen) -> QueryGen:
yield "?#|"
yield from ("?#|",) * len(rest)


class AsyncQuery:
def __init__(self, path, keys: typing.Sequence[Key], api):
self.path = path
Expand Down

0 comments on commit 01639e9

Please sign in to comment.