From e025e928b2453249a3dd2210925ede22d1c229a1 Mon Sep 17 00:00:00 2001 From: Sergey <6213510+sshnaidm@users.noreply.github.com> Date: Wed, 6 Sep 2023 13:28:52 +0300 Subject: [PATCH] Fix common file for Python 2.7 (#643) Signed-off-by: Sagi Shnaidman --- plugins/module_utils/podman/common.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/plugins/module_utils/podman/common.py b/plugins/module_utils/podman/common.py index 0e98f167..23f9e6f9 100644 --- a/plugins/module_utils/podman/common.py +++ b/plugins/module_utils/podman/common.py @@ -162,8 +162,10 @@ def generate_systemd(module, module_params, name, version): result['changed'] = True if result['diff'].get('before') is None: result['diff'] = {'before': {}, 'after': {}} - result['diff']['before'].update({f'systemd_{file_name}.service': ''}) - result['diff']['after'].update({f'systemd_{file_name}.service': file_content}) + result['diff']['before'].update( + {'systemd_{file_name}.service'.format(file_name=file_name): ''}) + result['diff']['after'].update( + {'systemd_{file_name}.service'.format(file_name=file_name): file_content}) else: diff_ = compare_systemd_file_content(os.path.join(full_path, file_name), file_content) @@ -171,14 +173,18 @@ def generate_systemd(module, module_params, name, version): result['changed'] = True if result['diff'].get('before') is None: result['diff'] = {'before': {}, 'after': {}} - result['diff']['before'].update({f'systemd_{file_name}.service': "\n".join(diff_[0])}) - result['diff']['after'].update({f'systemd_{file_name}.service': "\n".join(diff_[1])}) + result['diff']['before'].update( + {'systemd_{file_name}.service'.format(file_name=file_name): "\n".join(diff_[0])}) + result['diff']['after'].update( + {'systemd_{file_name}.service'.format(file_name=file_name): "\n".join(diff_[1])}) with open(os.path.join(full_path, file_name), 'w') as f: f.write(file_content) diff_before = "\n".join( - [f"{j} - {k}" for j, k in result['diff'].get('before', {}).items() if 'PIDFile' not in k]).strip() + ["{j} - {k}".format(j=j, k=k) + for j, k in result['diff'].get('before', {}).items() if 'PIDFile' not in k]).strip() diff_after = "\n".join( - [f"{j} - {k}" for j, k in result['diff'].get('after', {}).items() if 'PIDFile' not in k]).strip() + ["{j} - {k}".format(j=j, k=k) + for j, k in result['diff'].get('after', {}).items() if 'PIDFile' not in k]).strip() if diff_before or diff_after: result['diff']['before'] = diff_before + "\n" result['diff']['after'] = diff_after + "\n"