From 06fa841516fadf4454d8aa05609786a7b9f14b3b Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 12 Jan 2016 12:24:46 -0500 Subject: [PATCH] made loading of galaxy data files lazy --- lib/ansible/galaxy/__init__.py | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/lib/ansible/galaxy/__init__.py b/lib/ansible/galaxy/__init__.py index 62823fced47..e526b0aa873 100644 --- a/lib/ansible/galaxy/__init__.py +++ b/lib/ansible/galaxy/__init__.py @@ -49,11 +49,34 @@ class Galaxy(object): this_dir, this_filename = os.path.split(__file__) self.DATA_PATH = os.path.join(this_dir, "data") - #TODO: move to getter for lazy loading - self.default_readme = self._str_from_data_file('readme') - self.default_meta = self._str_from_data_file('metadata_template.j2') - self.default_test = self._str_from_data_file('test_playbook.j2') - self.default_travis = self._str_from_data_file('travis.j2') + self._default_readme = None + self._default_meta = None + self._default_test = None + self._default_travis = None + + @property + def default_readme(self): + if self._default_readme is None: + self._default_readme = self._str_from_data_file('readme') + return self._default_readme + + @property + def default_meta(self): + if self._default_meta is None: + self._default_meta = self._str_from_data_file('metadata_template.j2') + return self._default_meta + + @property + def default_test(self): + if self._default_test is None: + self._default_test = self._str_from_data_file('test_playbook.j2') + return self._default_test + + @property + def default_travis(self): + if self._default_travis is None: + self._default_travis = self._str_from_data_file('travis.j2') + return self._default_travis def add_role(self, role): self.roles[role.name] = role