def _make_data_for_template(self): """Generates data for spec template :returns: dictionary with required data """ data = { 'name': self.full_name, 'version': self.full_version, 'summary': self.meta['title'], 'description': self.meta['description'], 'license': ' and '.join(self.meta.get('licenses', [])), 'homepage': self.meta.get('homepage'), 'vendor': ', '.join(self.meta.get('authors', [])), 'year': utils.get_current_year()} uninst = utils.read_if_exist( join_path(self.plugin_path, "uninstall.sh")) preinst = utils.read_if_exist( join_path(self.plugin_path, "pre_install.sh")) postinst = utils.read_if_exist( join_path(self.plugin_path, "post_install.sh")) data.update( {'postinstall_hook': postinst, 'preinstall_hook': preinst, 'uninstall_hook': uninst} ) return data
def _make_data_for_template(self): data = super(BuildPluginV3, self)._make_data_for_template() uninst = utils.read_if_exist( join_path(self.plugin_path, "uninstall.sh")) preinst = utils.read_if_exist( join_path(self.plugin_path, "pre_install.sh")) postinst = utils.read_if_exist( join_path(self.plugin_path, "post_install.sh")) data.update( {'postinstall_hook': postinst, 'preinstall_hook': preinst, 'uninstall_hook': uninst} ) return data
def _make_data_for_template(self): data = super(BuildPluginV3, self)._make_data_for_template() uninst = utils.read_if_exist( join_path(self.plugin_path, "uninstall.sh")) preinst = utils.read_if_exist( join_path(self.plugin_path, "pre_install.sh")) postinst = utils.read_if_exist( join_path(self.plugin_path, "post_install.sh")) plugin_build_version = str(self.meta.get('build_version', '1')) data.update( {'postinstall_hook': postinst, 'preinstall_hook': preinst, 'uninstall_hook': uninst, 'build_version': plugin_build_version} ) return data
def test_read_if_exist_returns_empty(self, utils_exists): file_path = '/tmp/file' with mock.patch('__builtin__.open', self.mock_open("foo")): self.assertEqual(utils.read_if_exist(file_path), "") utils_exists.assert_called_once_with(file_path)