From 11b35c79ff8d2108d572929334e4e3f30c70eea5 Mon Sep 17 00:00:00 2001 From: "Vgr E.Barry" Date: Sat, 3 Jan 2015 19:33:15 -0500 Subject: [PATCH] Allow debug and verbose modes to be set directly from config. --- modules/__init__.py | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/modules/__init__.py b/modules/__init__.py index 1dcbf74..82d54bf 100644 --- a/modules/__init__.py +++ b/modules/__init__.py @@ -4,17 +4,6 @@ from settings import wolfgame as var # Todo: Allow game modes to be set via config -# Carry over settings from botconfig into settings/wolfgame.py - -for setting, value in botconfig.__dict__.items(): - if not setting.isupper(): - continue # Not a setting - if not setting in var.__dict__.keys(): - continue # Don't carry over config-only settings - - # If we got that far, it's valid - setattr(var, setting, value) - # Handle launch parameters # Argument --debug means start in debug mode @@ -26,8 +15,30 @@ parser.add_argument('--sabotage', action='store_true') parser.add_argument('--verbose', action='store_true') args = parser.parse_args() -botconfig.DEBUG_MODE = args.debug if not botconfig.DISABLE_DEBUG_MODE else False -botconfig.VERBOSE_MODE = args.verbose + +debug_mode = args.debug +verbose = args.verbose +sabotage = args.sabotage + +# Carry over settings from botconfig into settings/wolfgame.py + +for setting, value in botconfig.__dict__.items(): + if not setting.isupper(): + continue # Not a setting + if setting == "DEBUG_MODE": + debug_mode = value + if setting == "VERBOSE_MODE": + verbose = value + if setting == "DEFAULT_MODULE": + sabotage = value + if not setting in var.__dict__.keys(): + continue # Don't carry over config-only settings + + # If we got that far, it's valid + setattr(var, setting, value) + +botconfig.DEBUG_MODE = debug_mode if not botconfig.DISABLE_DEBUG_MODE else False +botconfig.VERBOSE_MODE = verbose botconfig.DEFAULT_MODULE = "sabotage" if args.sabotage else "wolfgame"