Fixed error handling in config class

This commit is contained in:
echel0n 2014-04-02 03:07:29 -07:00
commit 758c718d57

View file

@ -13,9 +13,9 @@ MOVIE_CONFIG_FILE = os.path.join(PROG_DIR, "autoProcessMovie.cfg")
TV_CONFIG_FILE = os.path.join(PROG_DIR, "autoProcessTv.cfg") TV_CONFIG_FILE = os.path.join(PROG_DIR, "autoProcessTv.cfg")
LOG_FILE = os.path.join(PROG_DIR, "postprocess.log") LOG_FILE = os.path.join(PROG_DIR, "postprocess.log")
class configParser(object): class config(object):
# link error handlers # link error handling classes
Error = ConfigParser.Error Error = ConfigParser.Error
NoSectionError = ConfigParser.NoSectionError NoSectionError = ConfigParser.NoSectionError
NoOptionError = ConfigParser.NoOptionError NoOptionError = ConfigParser.NoOptionError
@ -27,14 +27,12 @@ class configParser(object):
ParsingError = ConfigParser.ParsingError ParsingError = ConfigParser.ParsingError
MissingSectionHeaderError = ConfigParser.MissingSectionHeaderError MissingSectionHeaderError = ConfigParser.MissingSectionHeaderError
@staticmethod def __new__(cls, *file):
def config(*file): if not file:
# if no file specified then load our default config file = CONFIG_FILE
if not file:file = CONFIG_FILE
# load config # load config
parser = ConfigParser.ConfigParser() config = ConfigParser.ConfigParser()
parser.optionxform = str config.optionxform = str
if parser.read(file):return parser if config.read(file):
return config
config = configParser.config