-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenvironment.py
More file actions
32 lines (23 loc) · 1.17 KB
/
environment.py
File metadata and controls
32 lines (23 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import configparser
from pathlib import Path
import os
def read_config(file_path):
# Initialize the configparser
config = configparser.ConfigParser()
# Read the configuration file
config.read(file_path)
# Access the variables in the [DEFAULT] section
consumer_key = config['DEFAULT'].get('consumer_key', '')
consumer_secret = config['DEFAULT'].get('consumer_secret', '')
access_token = config['DEFAULT'].get('access_token', '')
access_token_secret = config['DEFAULT'].get('access_token_secret', '')
client_id = config['DEFAULT'].get('client_id', '')
client_secret = config['DEFAULT'].get('client_secret', '')
tinyurl_token = config['DEFAULT'].get('tinyurl_token', '')
shorturl_token = config['DEFAULT'].get('shorturl_token', '')
return consumer_key, consumer_secret, access_token, access_token_secret, client_id, client_secret, tinyurl_token, shorturl_token
# Example usage
home_dir = str(Path.home())
config_file_path = os.path.join(home_dir,'tldr_app_config.ini')
consumer_key, consumer_secret, access_token, \
access_token_secret, client_id, client_secret, tinyurl_token, shorturl_token = read_config(config_file_path)