Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_config_auth_object(auth_system: str) -> Dict[str, Any]:
config = tsrc.config.parse_tsrc_config()
auth = config.get("auth")
if not auth:
return {}
return cast(Dict[str, Any], auth.get(auth_system, {}))
def save_token(token: str, auth_system: str) -> None:
cfg_path = tsrc.config.get_tsrc_config_path()
if cfg_path.exists():
config = tsrc.config.parse_tsrc_config(roundtrip=True)
else:
config = tsrc.Config({})
if "auth" not in config:
config["auth"] = {}
auth = config["auth"]
if auth_system not in auth:
auth[auth_system] = {}
auth[auth_system]["token"] = token
tsrc.config.dump_tsrc_config(config)
def from_file(cls, cfg_path: Path) -> "ManifestConfig":
as_dict = tsrc.config.parse_config(cfg_path) # type: Dict[str, Any]
file_path = as_dict.get("file_path")
if file_path:
as_dict["file_path"] = Path(file_path)
return cls.from_dict(as_dict)
def save_token(token: str, auth_system: str) -> None:
cfg_path = tsrc.config.get_tsrc_config_path()
if cfg_path.exists():
config = tsrc.config.parse_tsrc_config(roundtrip=True)
else:
config = tsrc.Config({})
if "auth" not in config:
config["auth"] = {}
auth = config["auth"]
if auth_system not in auth:
auth[auth_system] = {}
auth[auth_system]["token"] = token
tsrc.config.dump_tsrc_config(config)
def save_token(token: str, auth_system: str) -> None:
cfg_path = tsrc.config.get_tsrc_config_path()
if cfg_path.exists():
config = tsrc.config.parse_tsrc_config(roundtrip=True)
else:
config = tsrc.Config({})
if "auth" not in config:
config["auth"] = {}
auth = config["auth"]
if auth_system not in auth:
auth[auth_system] = {}
auth[auth_system]["token"] = token
tsrc.config.dump_tsrc_config(config)