From 0375220258970a7376374859600c81d29cfdd0ea Mon Sep 17 00:00:00 2001 From: Benjamin Bohard Date: Wed, 10 Nov 2021 09:37:48 +0100 Subject: [PATCH] =?UTF-8?q?utiliser=20un=20formatage=20de=20cha=C3=AEne=20?= =?UTF-8?q?compatible=20python2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cadoles/eole/plugins/modules/instance.py | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/cadoles/eole/plugins/modules/instance.py b/cadoles/eole/plugins/modules/instance.py index dce6d9e..7a7a5e4 100644 --- a/cadoles/eole/plugins/modules/instance.py +++ b/cadoles/eole/plugins/modules/instance.py @@ -75,7 +75,7 @@ class ExpectationCollection: def add_expectation(self, expectation): if expectation.get_pattern() in self.expectations_lookup: if expectation.context in [exp.context for exp in self.expectations_lookup[expectation.get_pattern()]]: - print(f'Can not add {expectation} to collection') + print('Can not add {} to collection'.format(expectation)) return False self.expectations_lookup[expectation.get_pattern()] = self.expectations_lookup.setdefault(expectation.get_pattern(), []) + [expectation] return True @@ -123,7 +123,7 @@ class Expectation: self.next = {} def get_pattern(self, previous_answer=None): - return re.compile(f'(.*){re.escape(self.pattern.format(variable=previous_answer))}(.*)') + return re.compile(r'(.*){}(.*)'.format(re.escape(self.pattern.format(variable=previous_answer)))) def set_next_expectation(self, expectation, triggers=None): if not isinstance(triggers, list): @@ -132,19 +132,19 @@ class Expectation: self.next[trigger] = expectation def set_response(self, response): - print(f'Setting {response} for {self.pattern}') + print('Setting {} for {}'.format(response, self.pattern)) self.response = response def expect(self, spawned, previous_answer=None): - print(f'-> expecting next "{self.pattern.format(variable=previous_answer)}"') + print('-> expecting next "{}"'.format(self.pattern.format(variable=previous_answer))) p = spawned.expect([pexpect.EOF, pexpect.TIMEOUT, self.get_pattern(previous_answer=previous_answer)]) if p not in [0, 1]: self.answer(spawned) else: - print(f'-> before: {spawned.before}\n-> after: {spawned.after}\n-> {self.pattern}') + print('-> before: {}\n-> after: {}\n-> {}'.format(spawned.before, spawned_after, self.pattern)) def answer(self, spawned): - print(f'-> answering "{self.response}" to "{spawned.after}"') + print('-> answering "{}" to "{}"'.format(self.response, spawned.after)) if self.response is not None: spawned.sendline(self.response) if self.response in self.next: @@ -309,17 +309,17 @@ def run_module(): result['module'] = module.params["module"] if module.params.get('variables', None) and not set(module.params['variables'].keys()).issubset(set(expectations.get_exposed_expectation_names())): unknown_variables = list(set(module.params['variables'].keys()).difference(set(expectations.get_exposed_expectation_names()))) - result['msg'] += f"Variables {unknown_variables} not available\n" + result['msg'] += "Variables {} not available\n".format(unknown_variables) else: for variable in module.params.get('variables', {}).keys(): - result['msg'] += f"Overloading variable {variable}\n" + result['msg'] += "Overloading variable {}\n".format(variable) else: - result['msg'] += f'Module {module.module} not supported\n' + result['msg'] += 'Module {} not supported\n'.format(module.module) module.exit_json(**result) if module.params['module'] not in supported_modules: - result['msg'] += f"Unsupported module {module.params['module']}\n" + result['msg'] += "Unsupported module {}\n".format(module.params['module']) module.fail_json(**result) else: result['module'] = module.params['module'] @@ -327,7 +327,7 @@ def run_module(): if module.params.get('variables', None): if not set(module.params['variables'].keys()).issubset(set(expectations.get_exposed_expectation_names())): unknown_variables = list(set(module.params['variables'].keys()).difference(set(expectations.get_exposed_expectation_names()))) - result['msg'] += f"Variables {unknown_variables} not available\n" + result['msg'] += "Variables {} not available\n".format(unknown_variables) module.fail_json(**result) else: for expectation_name, response in module.params['variables'].items(): @@ -342,7 +342,7 @@ def run_module(): if p == 0: break if p == 1: - print(f'Some missing expectations for {instance_process.before}{instance_process.after}') + print('Some missing expectations for {}{}'.format(instance_process.before, instance_process.after)) break pattern = patterns[p] for expectation in expectations.get_expectations_by_pattern(patterns[p]): @@ -351,7 +351,7 @@ def run_module(): break some_index += 1 result['changed'] = True - result['msg'] += f"Module {result['module']} instanciated" + result['msg'] += "Module {} instanciated".format(result['module']) module.exit_json(**result) except Exception as err: result['msg'] += err