(self, dotenv_file:Path = None, user_id:str = None,
user_private_key:str = None, api_url:str = None,
encoding:SXTKeyEncodings = None, authenticate:bool = False,
application_name:str = None,
logger:logging.Logger = None,
SpaceAndTime_parent:object = None,
api_key:str = None, access_token:str = None,
**kwargs)
| 30 | __usrinfo__:dict = {} |
| 31 | |
| 32 | def __init__(self, dotenv_file:Path = None, user_id:str = None, |
| 33 | user_private_key:str = None, api_url:str = None, |
| 34 | encoding:SXTKeyEncodings = None, authenticate:bool = False, |
| 35 | application_name:str = None, |
| 36 | logger:logging.Logger = None, |
| 37 | SpaceAndTime_parent:object = None, |
| 38 | api_key:str = None, access_token:str = None, |
| 39 | **kwargs) -> None: |
| 40 | |
| 41 | # start with parent import |
| 42 | if SpaceAndTime_parent: |
| 43 | if not application_name: self.application_name = SpaceAndTime_parent.application_name |
| 44 | if not logger: logger = SpaceAndTime_parent.logger |
| 45 | self.start_time = SpaceAndTime_parent.start_time if SpaceAndTime_parent.start_time else datetime.datetime.now() |
| 46 | else: |
| 47 | self.start_time = datetime.datetime.now() |
| 48 | |
| 49 | if logger: |
| 50 | self.logger = logger |
| 51 | else: |
| 52 | self.logger = logging.getLogger() |
| 53 | self.logger.setLevel(logging.INFO) |
| 54 | if len(self.logger.handlers) == 0: |
| 55 | self.logger.addHandler( logging.StreamHandler() ) |
| 56 | self.logger.debug(f'SXT User instantiating...') |
| 57 | |
| 58 | encoding = encoding if encoding else SXTKeyEncodings.BASE64 |
| 59 | self.key_manager = SXTKeyManager(private_key = user_private_key, encoding = encoding, logger=self.logger) |
| 60 | self.base_api = SXTBaseAPI(logger = self.logger) |
| 61 | self.__bs = [] |
| 62 | self.__usrtyp__ = {'type':'', 'timeout':datetime.datetime.now()} |
| 63 | |
| 64 | # from dotenv file, if exists |
| 65 | dotenv_file = Path('./.env') if not dotenv_file and Path('./.env').resolve().exists() else dotenv_file |
| 66 | if dotenv_file: self.load(dotenv_file) |
| 67 | |
| 68 | # overwrite userid, api_url, and private key (and public key, by extension), if supplied |
| 69 | if user_private_key != None: self.private_key = user_private_key |
| 70 | if user_id != None: self.user_id = user_id |
| 71 | if api_url != None: self.base_api.api_url = api_url |
| 72 | if api_key != None: self.api_key = api_key |
| 73 | if access_token != None: self.access_token = access_token |
| 74 | |
| 75 | # get user info from the network and cache (sets __usrinfo__ if malformed) |
| 76 | self.__usrinfo__ = self.get_user_network_info() |
| 77 | |
| 78 | self.logger.info(f'SXT User instantiated: {self.user_id}') |
| 79 | if authenticate: self.authenticate() |
| 80 | |
| 81 | |
| 82 | @property |
nothing calls this directly
no test coverage detected