1""" 2Abstract base class for all library classes. 3""" 4# This module is part of the FritzConnection package. 5# https://github.com/kbr/fritzconnection 6# License: MIT (https://opensource.org/licenses/MIT) 7# Author: Klaus Bremer 8 9 10from ..core.fritzconnection import ( 11 FritzConnection, 12 DEFAULT_POOL_CONNECTIONS, 13 DEFAULT_POOL_MAXSIZE, 14) 15 16 17class AbstractLibraryBase: 18 """ 19 Abstract base class for library classes. Implements the common 20 initialisation. All parameters are optional. If given, they have the 21 following meaning: `fc` is an instance of FritzConnection, `address` 22 the ip of the Fritz!Box, `port` the port to connect to, `user` the 23 username, `password` the password, `timeout` a timeout as floating 24 point number in seconds, `use_tls` a boolean indicating to use TLS 25 (default False). `pool_connections` and `pool_maxsize` are to 26 override the urllib3 default settings. 27 """ 28 def __init__(self, fc=None, address=None, port=None, user=None, 29 password=None, timeout=None, use_tls=False, 30 pool_connections=DEFAULT_POOL_CONNECTIONS, 31 pool_maxsize=DEFAULT_POOL_MAXSIZE, 32 ): 33 if fc is None: 34 kwargs = { 35 k:v for k, v in locals().items() if k not in ('self', 'fc') 36 } 37 fc = FritzConnection(**kwargs) 38 self.fc = fc 39 40 @property 41 def modelname(self): 42 """ 43 The device modelname. Every library module derived from 44 `AbstractLibraryBase` inherits this property. 45 """ 46 return self.fc.modelname 47