[O] Make config path confiugrable
This commit is contained in:
@@ -13,7 +13,6 @@ import tweepy
|
|||||||
from raw_collect.utils import Config, debug, Posting, json_stringify, load_config
|
from raw_collect.utils import Config, debug, Posting, json_stringify, load_config
|
||||||
from tweepy import API
|
from tweepy import API
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class User:
|
class User:
|
||||||
id: int
|
id: int
|
||||||
|
|||||||
@@ -56,14 +56,15 @@ class Posting:
|
|||||||
date: datetime
|
date: datetime
|
||||||
|
|
||||||
|
|
||||||
def load_config() -> Config:
|
def load_config(path: str = 'config.json5') -> Config:
|
||||||
"""
|
"""
|
||||||
Load config using JSON5, from either the local file ~/config.json5 or from the environment variable named config.
|
Load config using JSON5, from either the local file ~/config.json5 or from the environment variable named config.
|
||||||
|
|
||||||
|
:param path: Path of the config file (Default: config.json5)
|
||||||
:return: Config object
|
:return: Config object
|
||||||
"""
|
"""
|
||||||
if os.path.isfile('config.json5'):
|
if os.path.isfile(path):
|
||||||
with open('config.json5', 'r') as f:
|
with open(path, 'r', encoding='utf-8') as f:
|
||||||
conf = json5.load(f)
|
conf = json5.load(f)
|
||||||
else:
|
else:
|
||||||
conf = json5.loads(os.getenv('config'))
|
conf = json5.loads(os.getenv('config'))
|
||||||
|
|||||||
Reference in New Issue
Block a user