Skip to content

Commit

Permalink
Issue #16 - Ignore missing default profile (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
kharyam authored Mar 24, 2022
1 parent e2fa65b commit 1096390
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/llgd/config/llgd_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
"""Manage custom profiles
"""
import configparser
from os import environ, path, makedirs
import logging
from os import environ, path, makedirs, getenv

logging.basicConfig(
format='%(asctime)s [%(levelname)s] %(message)s', level=getenv('LITRA_LOGLEVEL',
default='WARNING'))


class LlgdConfig:
Expand Down Expand Up @@ -110,8 +115,15 @@ def get_profile_names(self):
list[str]: Profile names
"""
profiles = self.config.sections()
profiles.remove(self.CURRENT_PROFILE_NAME)

try:
profiles.remove(self.CURRENT_PROFILE_NAME)
except ValueError:
logging.info(
'"%s" section not found in config file. Ignoring', self.CURRENT_PROFILE_NAME)

profiles.insert(0, self.CURRENT_PROFILE_NAME)

return profiles

def write_config(self):
Expand Down

0 comments on commit 1096390

Please sign in to comment.