Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reformat and redesign the recording output. #186

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mreg_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(
name: str,
description: str = "",
short_desc: str = "",
nargs: int = None,
nargs: str = "",
default: Any = None,
flag_type: Any = None,
choices: List[str] = None,
Expand Down
2 changes: 1 addition & 1 deletion mreg_cli/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def host_list(args: argparse.Namespace) -> None:

manager.add_line("Groups:")
for group in group_list:
manager.add_line(" ", group["name"])
manager.add_line(f" {group['name']}")


group.add_command(
Expand Down
6 changes: 3 additions & 3 deletions mreg_cli/outputmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ def __new__(cls):
def clear(self) -> None:
"""Clear the object."""
self._output: List[str] = []
self._filter_re: Any = None # should be re.Pattern, but python 3.6 doesn't have that
self._filter_re: Optional["re.Pattern[str]"] = None
self._filter_negate: bool = False
self._command_executed: str = None
self._command_issued: str = None
self._command_executed: str = ""
self._command_issued: str = ""

self._ok: List[str] = [] # This is typically commands that went OK but returned no content
self._warnings: List[str] = []
Expand Down
8 changes: 4 additions & 4 deletions mreg_cli/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import sys
from typing import TYPE_CHECKING, Dict, List, Optional, Union

from typing_extensions import Literal, TypeAlias # noqa: F401
pederhan marked this conversation as resolved.
Show resolved Hide resolved

if sys.version_info >= (3, 8):
from typing import Literal, TypedDict
from typing import TypedDict

class TimeInfo(TypedDict):
"""Type definition for time-related information in the recording entry."""
Expand All @@ -28,15 +30,13 @@ class RecordingEntry(TypedDict):
api_requests: List[str]
time: Optional[TimeInfo]

IP_Version = Literal[4, 6]

else:
from typing import Any

TimeInfo = Dict[str, Any]
RecordingEntry = Dict[str, Any]
IP_Version = int

IP_Version: "TypeAlias" = "Literal[4, 6]"
IP_network = Union[ipaddress.IPv4Network, ipaddress.IPv6Network]

if TYPE_CHECKING:
Expand Down
Loading