Refactor code to be more readable #46

Closed
erichardson wants to merge 4 commits from refactor-code into master
Showing only changes of commit a35d0cbb58 - Show all commits

View File

@@ -1,17 +1,8 @@
#===========================================================================
#
# Config file
#
#===========================================================================
__doc__ = """Config file parsing.
"""
"""Config file parsing."""
from .. import util
from ..util import config as C
#===========================================================================
# Config file section name and defaults.
configEntries = [
# ( name, converter function, default value )
@@ -22,15 +13,29 @@ configEntries = [
C.Entry("logLevel", int, 20), # INFO
]
#===========================================================================
def parse(configDir, configFile='eagle.py'):
"""
Parse the configuration file.
Args:
configDir (str): The directory containing the configuration file.
configFile (str): The name of the configuration file.
Returns:
dict: The parsed configuration.
"""
return C.readAndCheck(configDir, configFile, configEntries)
#===========================================================================
def log(config, logFile=None):
if not logFile:
logFile = config.logFile
"""
Get the logger configuration.
return util.log.get( "eagle", config.logLevel, logFile )
Args:
config (dict): The configuration dictionary.
logFile (str): The log file path.
#===========================================================================
Returns:
logger: The logger object.
"""
logFile = logFile or config['logFile']
return util.log.get("eagle", config['logLevel'], logFile)