[+] Create load config function

This commit is contained in:
Hykilpikonna
2021-11-03 15:34:32 -04:00
parent ad09a7fd04
commit c248e500a2
2 changed files with 24 additions and 0 deletions
Generated
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
+18
View File
@@ -0,0 +1,18 @@
import os
import json5
import tweepy
def load_config() -> dict:
"""
Load config using JSON5, from either the local file ~/config.json5 or from the environment variable named config.
:return: Config dictionary object
"""
if os.path.isfile('config.json5'):
with open('config.json5', 'r') as f:
return json5.load(f)
else:
return json5.loads(os.getenv('config'))