-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.py
More file actions
55 lines (42 loc) · 1.42 KB
/
start.py
File metadata and controls
55 lines (42 loc) · 1.42 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""
Starts of the script.
"""
import os
from dotenv import load_dotenv
from src import DiscordModule, TwitterModule, TelegramModule
load_dotenv()
def get_module(module_name: str):
"""
Factory function to get the appropriate module instance.
Parameters:
module_name (str): The name of the module to get (twitter, discord, telegram).
Returns:
IOInterface: An instance of the requested module.
Raises:
ValueError: If the module_name is not recognized.
"""
if module_name == "twitter":
return TwitterModule()
elif module_name == "discord":
return DiscordModule()
elif module_name == "telegram":
return TelegramModule()
else:
raise ValueError(f"Unknown module: {module_name}")
def main(source_m: str, target_m: str) -> None:
"""
Main processing starting point
"""
if source_m == target_m:
raise ValueError("Source and target cannot be the same.")
if source_m == "twitter":
raise ValueError("Source cannot be twitter, as twitter is \
write only as mentioned in the docs.")
source_module = get_module(source_m)
target_module = get_module(target_m)
data = source_module.read()
target_module.write(data)
if __name__ == "__main__":
source = os.getenv("SOURCE", None)
target = os.getenv("TARGET", None)
main(source, target)