2024-02-08 22:12:22 +00:00
|
|
|
from pathlib import Path
|
2024-02-11 18:00:48 +00:00
|
|
|
import json
|
2024-02-08 22:12:22 +00:00
|
|
|
|
2024-02-11 18:00:48 +00:00
|
|
|
import toml
|
|
|
|
|
|
|
|
from .utils import Paths, PROGRAM_NAME
|
2024-02-08 22:12:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
class PublishMeetups:
|
|
|
|
def __init__(self):
|
2024-02-11 18:00:48 +00:00
|
|
|
self.config_file: Path = Path(Paths.CONFIG_PATH, "publish-meetups.toml")
|
|
|
|
print(self.config_file)
|
|
|
|
self.config = {}
|
2024-02-08 22:12:22 +00:00
|
|
|
|
2024-02-11 18:00:48 +00:00
|
|
|
self.config = {
|
|
|
|
"active_feeds": [
|
|
|
|
"mastodon",
|
|
|
|
],
|
|
|
|
"mastodon": {},
|
2024-02-08 22:12:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def __enter__(self):
|
2024-02-11 18:00:48 +00:00
|
|
|
if self.config_file.exists():
|
|
|
|
with self.config_file.open("r") as f:
|
|
|
|
self.config.update(toml.load(f))
|
|
|
|
|
|
|
|
print(self.config['active_feeds'][0])
|
|
|
|
|
2024-02-08 22:12:22 +00:00
|
|
|
return self
|
|
|
|
|
|
|
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
2024-02-11 18:00:48 +00:00
|
|
|
with self.config_file.open("w") as f:
|
|
|
|
toml.dump(self.config, f)
|