Created
February 28, 2018 14:47
-
-
Save johnsca/7666f44928f4f9d94a4c1c8e4bcf4e5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bundle(dict) | |
def __init__(self, *args, **kwargs): | |
super().__init__(*args, **kwargs) | |
self._normalize_bundle() | |
def _normalize_bundle(self): | |
""" Normalizes bundle for things | |
like applications vs. services | |
""" | |
if 'services' in self: | |
self['applications'] = self.pop('services') | |
def to_yaml(self): | |
""" Returns yaml dump of bundle | |
""" | |
return yaml.dump(self, | |
default_flow_style=False) | |
@property | |
def applications(self): | |
""" Returns list of applications/services | |
""" | |
_applications = [] | |
for app in self['applications'].keys(): | |
_applications.append(self._get_application_fragment(app)) | |
return _applications | |
@property | |
def machines(self): | |
""" Returns defined machines | |
""" | |
return self.get('machines', []) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment