MCPcopy Index your code
hub / github.com/spaceandtimefdn/SxT-Python-SDK / load

Method load

src/spaceandtime/sxtuser.py:265–303  ·  view source on GitHub ↗

Load dotenv (.env) file / environment variables: API_URL, USERID, USER_PUBLIC_KEY, USER_PRIVATE_KEY, optionally USER_JOINCODE, USER_KEY_SCHEME, APP_PREFIX. Args: dotenv_file (Path): Path to .env file. If not set, first default is the file ./.env, second defalut is to

(self, dotenv_file:Path = None)

Source from the content-addressed store, hash-verified

263
264
265 def load(self, dotenv_file:Path = None):
266 """Load dotenv (.env) file / environment variables: API_URL, USERID, USER_PUBLIC_KEY, USER_PRIVATE_KEY, optionally USER_JOINCODE, USER_KEY_SCHEME, APP_PREFIX.
267
268 Args:
269 dotenv_file (Path): Path to .env file. If not set, first default is the file ./.env, second defalut is to load existing environment variables.
270
271 Returns:
272 None
273 """
274 load_dotenv(dotenv_file, override=True)
275 self.api_url = os.getenv('API_URL')
276
277 # add user_id from environment (including several options)
278 for userid_var in ['SXT_USER_ID', 'SXT_USERID', 'USER_ID', 'USERID']:
279 temp = os.getenv(userid_var)
280 if temp:
281 self.user_id = temp
282 break
283
284 # add user private key from environment (including several options)
285 for user_privatekey_var in ['SXT_USER_PRIVATE_KEY', 'SXT_USER_PRIVATEKEY', 'USER_PRIVATE_KEY', 'USER_PRIVATEKEY']:
286 temp = os.getenv(user_privatekey_var)
287 if temp:
288 self.private_key = temp
289 break
290
291 # add user API Key from environment (including several options)
292 for user_privatekey_var in ['SXT_USER_API_KEY', 'SXT_USER_APIKEY', 'USER_API_KEY', 'USER_APIKEY']:
293 temp = os.getenv(user_privatekey_var)
294 if temp:
295 self.api_key = temp
296 break
297
298 # TODO: Right now, only ED25519 authentication is supported. Add Eth wallet support, or other future schemes
299 # self.key_scheme = os.getenv('USER_KEY_SCHEME')
300
301 loc = str(dotenv_file) if dotenv_file and Path(dotenv_file).exists() else 'default .env location'
302 self.logger.info(f'dotenv loaded')
303 return None
304
305
306 def save(self, dotenv_file:Path = None):

Callers 1

__init__Method · 0.95

Calls 1

existsMethod · 0.45

Tested by

no test coverage detected