def test_confirm_overwrite(self): with patch('sys.stdin') as r: # Overwrite yes r.readline = Mock(return_value='y') eq_(confirm_overwrite('.lamvery.yml'), True) # Overwrite no r.readline = Mock(return_value='n') eq_(confirm_overwrite('.lamvery.yml'), False)
def action(self): if confirm_overwrite(self._conf_file): self._config.write(self._config.get_default(), self._conf_file) self._logger.info('Output initial file: {}'.format( self._conf_file)) files = { self._config.get_event_file(): self._config.get_default_events(), self._config.get_secret_file(): self._config.get_default_secret(), self._config.get_exclude_file(): self._config.get_default_exclude(), self._config.get_hook_file(): self._config.get_default_hook(), self._config.get_api_file(): self._config.get_default_api(), } for f, c in files.items(): if confirm_overwrite(f): self._config.write(c, f) self._logger.info('Output initial file: {}'.format(f))
def action(self): if confirm_overwrite(self._conf_file): self._config.write(self._config.get_default(), self._conf_file) self._logger.info( 'Output initial file: {}'.format(self._conf_file)) files = { self._config.get_event_file(): self._config.get_default_events(), self._config.get_secret_file(): self._config.get_default_secret(), self._config.get_exclude_file(): self._config.get_default_exclude(), self._config.get_hook_file(): self._config.get_default_hook(), self._config.get_api_file(): self._config.get_default_api(), } for f, c in files.items(): if confirm_overwrite(f): self._config.write(c, f) self._logger.info( 'Output initial file: {}'.format(f))
def _generate_function(self, namespace, function, runtime): if 'python' in runtime: path = '{}.py'.format(namespace) content = PY_CODE.format(function) elif 'nodejs' in runtime: path = '{}.js'.format(namespace) content = JS_CODE.format(function) else: raise Exception('Runtime "{}" is not supported.'.format(runtime)) if confirm_overwrite(path): open(path, 'w').write(content) self._logger.info('Output skeleton function: {}'.format(path))