Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions docs/hooks/shortcodes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Shortcodes hook.
"""
Shortcodes hook.

Origin source:
https://github.com/squidfunk/mkdocs-material/blob/master/src/overrides/hooks/shortcodes.py
Expand Down Expand Up @@ -112,7 +113,6 @@ def on_page_markdown(

def replace(match: Match, page: Page | None = None, files: Files | None = None):
"""Shortcodes replacer."""

type, args = match.groups()
args = args.strip()

Expand Down
8 changes: 6 additions & 2 deletions docs/project/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ isort .
# Spelling check
codespell .

# Format docstring with docformatter
docformatter --recursive --black --in-place .
# Format docstring with docformatter
# (for onvif, tests, and docs folders only)
docformatter --recursive --black --in-place onvif tests docs

# Format code with black
black .
Expand Down Expand Up @@ -216,13 +217,16 @@ The documentation source is located in the [`docs/`](https://github.com/nirsimet
```text
docs/
├── assets/
├── generated/
├── hooks/
├── javascripts/
├── stylesheets/
├── overrides/
├── templates/
├── includes/
├── api/
├── main/
├── misc/
├── references/
├── utilities/
├── project/
Expand Down
6 changes: 4 additions & 2 deletions onvif/cli/helpers/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def discover_devices(
prefer_https: bool = False,
filter_term: str | None = None,
) -> list:
"""Discover ONVIF devices on the network using WS-Discovery.
"""
Discover ONVIF devices on the network using WS-Discovery.

Args:
timeout (int): Discovery timeout in seconds
Expand Down Expand Up @@ -42,7 +43,8 @@ def discover_devices(


def select_device_interactive(devices: list) -> tuple[str, int, bool] | None:
"""Display devices and allow user to select one interactively.
"""
Display devices and allow user to select one interactively.

Args:
devices (list): Discovered devices
Expand Down
3 changes: 2 additions & 1 deletion onvif/cli/helpers/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def execute_command(
method_name: str,
params_str: str | None = None,
) -> Any:
"""Execute a single ONVIF command.
"""
Execute a single ONVIF command.

Args:
client (ONVIFClient): ONVIFClient instance
Expand Down
6 changes: 4 additions & 2 deletions onvif/cli/helpers/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
def save_output_to_file(
result: Any, output_path: str, debug_mode: bool, client: ONVIFClient
) -> None:
"""Save command output to file in appropriate format based on file extension.
"""
Save command output to file in appropriate format based on file extension.

Args:
result (Any): The ONVIF command result
Expand Down Expand Up @@ -106,7 +107,8 @@ def save_output_to_file(

# pylint: disable=too-many-return-statements,too-many-branches,too-many-nested-blocks
def _serialize_for_json(obj: Any) -> Any:
"""Recursively serialize ONVIF objects for JSON output.
"""
Recursively serialize ONVIF objects for JSON output.

Args:
obj: Object to serialize
Expand Down
10 changes: 5 additions & 5 deletions onvif/cli/helpers/products.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@


def search_products(search_term: str, page: int = 1, per_page: int = 20) -> None:
"""Search ONVIF products database and display results in table format with
pagination.
"""
Search ONVIF products database and display results in table format with pagination.

Args:
search_term (str): Search term to match against model, post_title, and company_name fields
Expand Down Expand Up @@ -244,7 +244,7 @@ def _format_date_width(value: str) -> str:


def _print_data_header(headers: list[str], col_widths: list[int]) -> None:
"""Print table header"""
"""Print table header."""
header_line = " | ".join(
header.ljust(col_widths[i]) for i, header in enumerate(headers)
)
Expand All @@ -254,7 +254,7 @@ def _print_data_header(headers: list[str], col_widths: list[int]) -> None:

# pylint: disable=too-many-branches,too-many-nested-blocks
def _print_data_rows(results: list[Any], col_widths: list[int]) -> None:
"""Print data table rows"""
"""Print data table rows."""
for row in results:
formatted_row = []
for i, value in enumerate(row):
Expand Down Expand Up @@ -322,7 +322,7 @@ def _print_data_rows(results: list[Any], col_widths: list[int]) -> None:


def _print_data_pagination(page: int, total_pages: int) -> None:
"""Print pagination information"""
"""Print pagination information."""
print()
newline = "\n" if total_pages == 1 else ""
print(f"{colorize(f'Page {page} of {total_pages}', 'cyan')} {newline}")
Expand Down
24 changes: 16 additions & 8 deletions onvif/cli/helpers/wsdl_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class OperationTypeInfo(TypedDict):
def get_method_documentation(
service_obj: Any, method_name: str
) -> dict[str, Any] | None:
"""Extracts documentation from WSDL and parameters from the Python method signature.
"""
Extracts documentation from WSDL and parameters from the Python method signature.

Returns a dictionary with 'doc', 'required', and 'optional' keys.
"""
Expand Down Expand Up @@ -177,7 +178,8 @@ def get_method_documentation(
def get_operation_type_info(
service_obj: Any, operation_name: str
) -> OperationTypeInfo | None:
"""Extract input and output message types from WSDL for a given operation.
"""
Extract input and output message types from WSDL for a given operation.

Returns a dictionary with 'input' and 'output' keys containing message details.
"""
Expand Down Expand Up @@ -250,7 +252,8 @@ def get_operation_type_info(
def parse_message_from_wsdl(
root, message_name: str, namespaces: dict, schema_context: dict
) -> MessageInfo | None:
"""Parse a WSDL message definition to extract parameter details.
"""
Parse a WSDL message definition to extract parameter details.

Returns a dictionary with message name and parameters.
"""
Expand Down Expand Up @@ -295,7 +298,8 @@ def parse_message_from_wsdl(


def clean_documentation_html(doc_text: str) -> str:
"""Clean HTML tags from documentation text and convert links to readable format.
"""
Clean HTML tags from documentation text and convert links to readable format.

Args:
doc_text: Documentation text that may contain HTML tags
Expand Down Expand Up @@ -333,7 +337,8 @@ def replace_link(match):


def extract_documentation_text(doc_elem) -> str:
"""Extract full text from xs:documentation element including child elements.
"""
Extract full text from xs:documentation element including child elements.

This handles cases where documentation contains HTML tags like <a href="">.

Expand Down Expand Up @@ -457,7 +462,8 @@ def resolve_element_type(
depth: int = 0,
visited: set[str] | None = None,
) -> list:
"""Resolve an element definition from the schema to get its parameters recursively.
"""
Resolve an element definition from the schema to get its parameters recursively.

Args:
element_name: Name of the element to resolve
Expand Down Expand Up @@ -620,7 +626,8 @@ def resolve_complex_type(
depth: int = 0,
visited: set[str] | None = None,
) -> list:
"""Resolve a complexType definition to get its child elements.
"""
Resolve a complexType definition to get its child elements.

Args:
type_name: Name of the complexType to resolve
Expand Down Expand Up @@ -810,7 +817,8 @@ def parse_inline_complex_type(
depth: int = 0,
visited: set[str] | None = None,
) -> list:
"""Parse an inline complexType element (not referenced by name).
"""
Parse an inline complexType element (not referenced by name).

Args:
complex_type: The xs:complexType element itself
Expand Down
9 changes: 6 additions & 3 deletions onvif/cli/interactive/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def do_store(self, line) -> None:

def do_show(self, line) -> None:
"""Show stored data: show <name> or show <name>.<attribute> or show
<name>[index]"""
<name>[index]
"""
if not line:
print(colorize("Stored data:", "green"))
for name in self.context.stored_data:
Expand All @@ -91,7 +92,8 @@ def do_show(self, line) -> None:
print(f"{colorize('Error:', 'red')} Cannot resolve '{line}'")

def _substitute_stored_references(self, params_str: str) -> str:
"""Substitute $variable references in parameter string with stored data.
"""
Substitute $variable references in parameter string with stored data.

Args:
params_str: Parameter string that may contain $variable references
Expand Down Expand Up @@ -124,7 +126,8 @@ def replace_reference(match) -> Any | str:
return re.sub(pattern, replace_reference, params_str)

def _resolve_stored_reference(self, reference: str) -> Any | None:
"""Resolve stored data reference like 'profiles[0].token' or 'profiles.Token'.
"""
Resolve stored data reference like 'profiles[0].token' or 'profiles.Token'.

Args:
reference: String reference like 'profiles[0]' or 'profiles.Token'
Expand Down
9 changes: 6 additions & 3 deletions onvif/cli/interactive/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def execute_service_method(self, method_name: str, params_str: str) -> None:
traceback.print_exc()

def do_desc(self, line) -> None:
"""Describes a method from its WSDL documentation.
"""
Describes a method from its WSDL documentation.

Usage: desc <method_name>
"""
Expand Down Expand Up @@ -149,7 +150,8 @@ def do_desc(self, line) -> None:

# pylint: disable=too-many-branches
def do_type(self, line) -> None:
"""Show input and output types for a method.
"""
Show input and output types for a method.

Usage: type <method_name>
"""
Expand Down Expand Up @@ -180,7 +182,8 @@ def do_type(self, line) -> None:
# Helper function to display parameters recursively with tree-style indentation
# pylint: disable=too-many-branches
def display_params(params, prefix_lines=None, is_root_level=False):
"""Display parameters with tree-style formatting.
"""
Display parameters with tree-style formatting.

Args:
params: List of parameter dictionaries
Expand Down
3 changes: 2 additions & 1 deletion onvif/cli/interactive/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ def cmdloop(self, intro=None):

def onecmd(self, line):
"""Override onecmd to handle service method calls without showing cmd.Cmd
traceback."""
traceback.
"""
line = line.strip()
if not line:
return self.emptyline()
Expand Down
5 changes: 3 additions & 2 deletions onvif/cli/interactive/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,9 @@ def _handle_connection_error(self) -> None:
sys.exit(1)

def _split_multi_commands(self, s: str) -> list:
"""Split a command string by top-level '&&' separators while ignoring
occurrences inside quotes or bracketed structures.
"""
Split a command string by top-level '&&' separators while ignoring occurrences
inside quotes or bracketed structures.

Returns a list of command strings (trimmed).
"""
Expand Down
12 changes: 8 additions & 4 deletions onvif/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def _is_valid_json(s: str) -> bool:

# pylint: disable=too-many-branches
def parse_json_params(params_str: str) -> dict[str, Any]:
"""Parse parameters from a JSON string or key=value pairs into a dict.
"""
Parse parameters from a JSON string or key=value pairs into a dict.

Supports:
- JSON: '{"a": 1, "b": 2}'
Expand Down Expand Up @@ -139,7 +140,8 @@ def split_top_level(s: str):


def get_service_required_args(service_name: str) -> list[str] | None:
"""Get required arguments for services that need them.
"""
Get required arguments for services that need them.

Returns list of required argument names, or None if service doesn't need args.

Expand Down Expand Up @@ -290,7 +292,8 @@ def format_capabilities_as_services(capabilities) -> str:


def format_services_list(services_list: list) -> str:
"""Format GetServices response as service list with XAddr and binding support.
"""
Format GetServices response as service list with XAddr and binding support.

Shows binding information for all services (single and multi-binding).
"""
Expand Down Expand Up @@ -354,7 +357,8 @@ def format_services_list(services_list: list) -> str:

# pylint: disable=too-many-branches
def get_device_available_services(client) -> list:
"""Get list of services actually available on the connected device.
"""
Get list of services actually available on the connected device.

For multi-binding services, returns all available service names.
"""
Expand Down
Loading
Loading