Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _setup_parser(self, filename=None):
"""
Configure the ConfigParser instance the way we want it.
Args:
filename (str) or None
Returns:
SafeConfigParser
"""
assert isinstance(filename, str) or filename is None
# If we are not overriding the config filename
if not filename:
filename = MACKUP_CONFIG_FILE
parser = configparser.SafeConfigParser(allow_no_value=True)
parser.read(os.path.join(os.path.join(os.environ["HOME"], filename)))
return parser
# Is an old setion is in the config file ?
old_sections = ["Allowed Applications", "Ignored Applications"]
for old_section in old_sections:
if self._parser.has_section(old_section):
error(
"Old config file detected. Aborting.\n"
"\n"
"An old section (e.g. [Allowed Applications]"
" or [Ignored Applications] has been detected"
" in your {} file.\n"
"I'd rather do nothing than do something you"
" do not want me to do.\n"
"\n"
"Please read the up to date documentation on"
" and migrate"
" your configuration file.".format(MACKUP_CONFIG_FILE)
)