forked from randsleadershipslack/destalinator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
executable file
·24 lines (21 loc) · 718 Bytes
/
Copy pathutil.py
File metadata and controls
executable file
·24 lines (21 loc) · 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#! /usr/bin/env python
import os
def get_token(token, token_file, token_env_variable):
"""
if token, returns it
if token is None, and token_file is not None,
reads content of token_file and returns that
If token is None, token_file is None, and token_env_variable is not None,
return the value of that.
if all are None (or empty), asserts an error
"""
if token is None and token_file:
f = open(token_file, "r")
token = f.read().strip()
f.close()
if token is None and token_file is None and token_env_variable:
token = os.getenv(token_env_variable)
if token == "":
token = None
assert token is not None
return token