Extended (add, delete) and improved profile handling
This commit is contained in:
parent
c45c10a49d
commit
9171871af0
2 changed files with 80 additions and 16 deletions
16
mcg.py
16
mcg.py
|
|
@ -612,6 +612,12 @@ class MCGProfileConfig(MCGConfig):
|
|||
self._profiles.append(profile)
|
||||
|
||||
|
||||
def delete_profile(self, profile):
|
||||
if profile in self._profiles:
|
||||
self._profiles.remove(profile)
|
||||
self._force_default_profile()
|
||||
|
||||
|
||||
def get_profiles(self):
|
||||
return self._profiles
|
||||
|
||||
|
|
@ -630,6 +636,7 @@ class MCGProfileConfig(MCGConfig):
|
|||
if self.has_option(section, attribute):
|
||||
profile.set(attribute, self.get(section, attribute))
|
||||
self._profiles.append(profile)
|
||||
self._force_default_profile()
|
||||
|
||||
|
||||
def save(self):
|
||||
|
|
@ -647,6 +654,11 @@ class MCGProfileConfig(MCGConfig):
|
|||
super().save()
|
||||
|
||||
|
||||
def _force_default_profile(self):
|
||||
if len(self._profiles) == 0:
|
||||
self._profiles.append(MCGProfile())
|
||||
|
||||
|
||||
|
||||
|
||||
class MCGConfigurable:
|
||||
|
|
@ -681,6 +693,10 @@ class MCGProfile(MCGConfigurable):
|
|||
self.set('tags', "")
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return self.get("host")
|
||||
|
||||
|
||||
def get_tags(self):
|
||||
return self.get('tags').split(',')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue