give config to package defined actions
This commit is contained in:
@@ -6,7 +6,8 @@ import datetime
|
|||||||
import pytz
|
import pytz
|
||||||
from dateutil import parser as dateutilparser
|
from dateutil import parser as dateutilparser
|
||||||
|
|
||||||
def clean_data():
|
|
||||||
|
def clean_data(config):
|
||||||
open(config["top_mbox_file"], 'w').close()
|
open(config["top_mbox_file"], 'w').close()
|
||||||
|
|
||||||
|
|
||||||
@@ -18,10 +19,10 @@ def clean_data():
|
|||||||
if "file" in top and os.path.isfile(top["file"]):
|
if "file" in top and os.path.isfile(top["file"]):
|
||||||
os.remove(top["file"])
|
os.remove(top["file"])
|
||||||
|
|
||||||
def read_db():
|
def read_db(config):
|
||||||
subprocess.run(["helpers/read_db.sh"], check=True)
|
subprocess.run(["helpers/read_db.sh"], check=True)
|
||||||
|
|
||||||
def read_topmails():
|
def read_topmails(config):
|
||||||
in_mbox = mailbox.Maildir(config["top_inbox_maildir"])
|
in_mbox = mailbox.Maildir(config["top_inbox_maildir"])
|
||||||
out_mbox = mailbox.mbox(config["top_mbox_file"])
|
out_mbox = mailbox.mbox(config["top_mbox_file"])
|
||||||
|
|
||||||
@@ -45,5 +46,5 @@ def read_topmails():
|
|||||||
|
|
||||||
out_mbox.close()
|
out_mbox.close()
|
||||||
|
|
||||||
def compile_presentation():
|
def compile_presentation(config):
|
||||||
subprocess.run(["helpers/compile_presentation.sh"], check=True)
|
subprocess.run(["helpers/compile_presentation.sh"], check=True)
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ def main(rawargs=None):
|
|||||||
parser.add_argument("--date")
|
parser.add_argument("--date")
|
||||||
args = parser.parse_args(rawargs)
|
args = parser.parse_args(rawargs)
|
||||||
|
|
||||||
|
global config
|
||||||
config = util.get_config(util.get_normalized_config_path(args.config))
|
config = util.get_config(util.get_normalized_config_path(args.config))
|
||||||
|
|
||||||
if args.print_config:
|
if args.print_config:
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class BuiltinActions:
|
|||||||
|
|
||||||
def dispatch(action, args=[]):
|
def dispatch(action, args=[]):
|
||||||
if package_actions and action in dir(package_actions):
|
if package_actions and action in dir(package_actions):
|
||||||
getattr(package_actions, action)(*args)
|
getattr(package_actions, action)(config, *args)
|
||||||
elif action in dir(BuiltinActions):
|
elif action in dir(BuiltinActions):
|
||||||
getattr(BuiltinActions, action)(*args)
|
getattr(BuiltinActions, action)(*args)
|
||||||
elif action in config["sequencer"]:
|
elif action in config["sequencer"]:
|
||||||
|
|||||||
Reference in New Issue
Block a user