MCPcopy
hub / github.com/spaceandtimefdn/SxT-Python-SDK / SpaceAndTime

Class SpaceAndTime

src/spaceandtime/spaceandtime.py:16–420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14from sxtexceptions import *
15
16class SpaceAndTime:
17
18 user: SXTUser = None
19 application_name: str = 'SxT-SDK'
20 network_calls_enabled:bool = True
21 default_local_folder:str = None
22 envfile_filepath:str = None
23 start_time: datetime = None
24 key_manager: SXTKeyManager = None
25 GRANT = SXTPermission
26 ENCODINGS = SXTKeyEncodings
27 SQLTYPE = SXTSqlType
28 OUTPUT_FORMAT = SXTOutputFormat
29 TABLE_ACCESS = SXTTableAccessType
30 DISCOVERY_SCOPE = SXTDiscoveryScope
31
32
33 def __init__(self, envfile_filepath=None, api_url=None,
34 user_id=None, user_private_key=None,
35 default_local_folder:str = None,
36 application_name='SxT-SDK',
37 logger: logging.Logger = None,
38 api_key:str = None,
39 authenticate:bool = False):
40 """Create new instance of Space and Time SDK for Python"""
41 if logger:
42 self.logger = logger
43 else:
44 self.logger = logging.getLogger()
45 self.logger.setLevel(logging.INFO)
46 frmt = logging.Formatter('%(asctime)s %(levelname)-8s %(message)s','%Y-%m-%d_%H:%M:%S')
47 self.logger.sxtformat = frmt
48 if len(self.logger.handlers) == 0:
49 self.logger.addHandler( logging.StreamHandler() )
50 self.logger.handlers[0].formatter = frmt
51
52 self.start_time = datetime.now()
53 self.logger.info('-'*30 + f'\nSpace and Time SDK initiated for {self.application_name} at {self.start_time.strftime("%Y-%m-%d %H:%M:%S")}')
54
55 if application_name: self.application_name = application_name
56 self.default_local_folder = default_local_folder if default_local_folder else Path('.').resolve()
57 self.envfile_filepath = envfile_filepath if envfile_filepath else self.default_local_folder
58
59 self.user = SXTUser(dotenv_file=envfile_filepath, api_url=api_url, user_id=user_id, user_private_key=user_private_key, logger=self.logger, api_key=api_key)
60 self.key_manager = self.user.key_manager
61
62 if authenticate: self.authenticate()
63 return None
64
65 @property
66 def access_token(self) -> str:
67 return self.user.access_token
68
69 @property
70 def refresh_token(self) -> str:
71 return self.user.refresh_token
72
73 @property

Callers 13

mainFunction · 0.90
test_table_discoveryFunction · 0.90
test_apikey_loginFunction · 0.90
test_sxt_addfilehandlerFunction · 0.90
test_sxt_exceptionsFunction · 0.90
test_sxt_wrapperFunction · 0.90
test_execute_queryFunction · 0.90
test_discoveryFunction · 0.90

Calls

no outgoing calls

Tested by 10

test_table_discoveryFunction · 0.72
test_apikey_loginFunction · 0.72
test_sxt_addfilehandlerFunction · 0.72
test_sxt_exceptionsFunction · 0.72
test_sxt_wrapperFunction · 0.72
test_execute_queryFunction · 0.72
test_discoveryFunction · 0.72