Skip to content

Commit b430fa1

Browse files
committed
combining configs
1 parent bfa8b3c commit b430fa1

4 files changed

Lines changed: 15 additions & 20 deletions

File tree

‎config.template.json‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
{
22
"authToken": "xxx",
33
"secretKey": "xxx",
4+
"twitter": {
5+
"api": {
6+
"key": "xxx",
7+
"secret": "xxx"
8+
},
9+
"access": {
10+
"token": "xxx",
11+
"token-secret": "xxx"
12+
}
13+
},
414
"tweetsFetchSettings": {
515
"default": "live",
616
"list": {

‎lib/shared.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@
1111
config = json.load(f)
1212

1313
tweetsFetchSettings = config['tweetsFetchSettings']['list'][config['tweetsFetchSettings']['default']]
14+
1415
authToken = config['authToken']
1516
secretKey = config['secretKey']
17+
twitterAuth = config['twitter']

‎lib/twitter_auth.py‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
11
from tweepy import AppAuthHandler, OAuthHandler, API
2-
from .shared import base_folder
2+
from .shared import base_folder, twitterAuth
33
import json
44
import os
55

6-
def read_auth_json():
7-
ad = None
8-
with open(os.path.join(base_folder, 'twitter-auth.json')) as json_file:
9-
ad = json.load(json_file)
10-
if ad is None:
11-
raise Exception('Auth missing')
12-
return ad
136

147
def get_auth_app():
15-
ad = read_auth_json()['api']
8+
ad = twitterAuth['api']
169
return AppAuthHandler(ad['key'], ad['secret'])
1710

1811
def get_api_app():
1912
return API(get_auth_app())
2013

2114
def get_auth_user():
22-
ad = read_auth_json()
15+
ad = twitterAuth
2316
auth = OAuthHandler(ad['api']['key'], ad['api']['secret'])
2417
auth.set_access_token(ad['access']['token'], ad['access']['token-secret'])
2518
return auth

‎twitter-auth.template.json‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)