From d481a8a718c2c22f3e5070892373ecb55633b3f6 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sun, 20 Dec 2020 04:06:17 -0600 Subject: Add docstrings to default connection --- lirc/connection/default_connection.py | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/lirc/connection/default_connection.py b/lirc/connection/default_connection.py index 4adb43f..5af80db 100644 --- a/lirc/connection/default_connection.py +++ b/lirc/connection/default_connection.py @@ -1,26 +1,46 @@ import platform -import socket as stdlib_socket +import socket from typing import Tuple, Union class DefaultConnection: def __init__(self): + """ + This class provides our operating specific default + connection parameters. + """ self.__operating_system = platform.system().capitalize() @property - def socket(self) -> stdlib_socket.socket: + def socket(self) -> socket.socket: + """ + Retreives the default socket that should be used + for lircd on the current operating system. + + Returns: + A socket.socket setup correctly for the current OS. + """ if self.__operating_system == "Linux" or self.__operating_system == "Darwin": - return stdlib_socket.socket( - stdlib_socket.AF_UNIX, stdlib_socket.SOCK_STREAM + return socket.socket( + socket.AF_UNIX, socket.SOCK_STREAM ) if self.__operating_system == "Windows": - return stdlib_socket.socket( - stdlib_socket.AF_INET, stdlib_socket.SOCK_STREAM + return socket.socket( + socket.AF_INET, socket.SOCK_STREAM ) @property def address(self) -> Union[str, Tuple[str, int]]: + """ + Retrieves the default address that should be used + for lircd on the current operating system. + + Returns: + A str path to the lircd socket on the file system + if on Linux or MacOS; a Tuple of the address and port + if on Windows. + """ return { "Linux": "/var/run/lirc/lircd", "Windows": ("localhost", 8765), -- cgit v1.2.3