From 5b1e07450fec0f015de629131bc4e620e07889fa Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sun, 17 May 2026 11:52:31 +0200 Subject: reformat Python files --- plugins/action/apt_wrapper.py | 2 +- plugins/action/etckeeper_commit.py | 7 +++++-- plugins/action/safe_git.py | 12 +++++++++--- plugins/module_utils/git.py | 30 ++++++++++++++++++++++++------ 4 files changed, 39 insertions(+), 12 deletions(-) (limited to 'plugins') diff --git a/plugins/action/apt_wrapper.py b/plugins/action/apt_wrapper.py index b322e10..804454b 100755 --- a/plugins/action/apt_wrapper.py +++ b/plugins/action/apt_wrapper.py @@ -22,7 +22,7 @@ class ActionModule(ActionBase): after = self._parse_dpkg_log(task_vars) - apt_result['packages'] = after[len(before):] + apt_result['packages'] = after[len(before) :] return apt_result def _parse_dpkg_log(self, task_vars, default=None): diff --git a/plugins/action/etckeeper_commit.py b/plugins/action/etckeeper_commit.py index d16e66f..06c7be0 100755 --- a/plugins/action/etckeeper_commit.py +++ b/plugins/action/etckeeper_commit.py @@ -24,11 +24,14 @@ class ActionModule(ActionBase): if allowlist: unexpected = [ - path for path in dirty_files + path + for path in dirty_files if not any([pattern.fullmatch(path) for pattern in allowlist]) ] if unexpected: - raise AnsibleActionFail(f"Unexpected modifications in repository:\n{'\n'.join(unexpected)}") + raise AnsibleActionFail( + f"Unexpected modifications in repository:\n{'\n'.join(unexpected)}" + ) return self._commit(msg, task_vars) diff --git a/plugins/action/safe_git.py b/plugins/action/safe_git.py index 7615236..8389169 100755 --- a/plugins/action/safe_git.py +++ b/plugins/action/safe_git.py @@ -34,12 +34,16 @@ class ActionModule(ActionBase): # ansible.builtin.git would just remove everything, fuck that. if not git.is_work_tree(self, dest, task_vars): - raise AnsibleActionFail(f'Destination {dest} exists but is not a repository') + raise AnsibleActionFail( + f'Destination {dest} exists but is not a repository' + ) # Again, ansible.builtin.git would just remove everything, fuck that. current_url = git.get_remote_url(self, dest, task_vars, remote=remote) if current_url != repo: - raise AnsibleActionFail(f"Existing remote URL '{current_url}' doesn't match '{repo}' for {dest}") + raise AnsibleActionFail( + f"Existing remote URL '{current_url}' doesn't match '{repo}' for {dest}" + ) # ansible.builtin.git would abort if the `force` parameter is set to # `false`, but I don't want to depend on default values. @@ -54,7 +58,9 @@ class ActionModule(ActionBase): # (again, unlike the builtin module). is_ancestor = git.is_ancestor(self, dest, remote, version, task_vars) if not is_ancestor: - raise AnsibleActionFail(f'HEAD in {dest} is not an ancestor of {remote}/{version}') + raise AnsibleActionFail( + f'HEAD in {dest} is not an ancestor of {remote}/{version}' + ) # Finally, everything looks good, delegate to the builtin module. return self._execute_module( diff --git a/plugins/module_utils/git.py b/plugins/module_utils/git.py index dec54c5..d9c5f35 100644 --- a/plugins/module_utils/git.py +++ b/plugins/module_utils/git.py @@ -27,7 +27,9 @@ def get_status(action, repo_dir, task_vars): task_vars=task_vars, ) if cmd_result.get('failed'): - raise AnsibleActionFail(f"Couldn't get git status for {repo_dir}", result=cmd_result) + raise AnsibleActionFail( + f"Couldn't get git status for {repo_dir}", result=cmd_result + ) return to_text(cmd_result['stdout']) @@ -48,7 +50,10 @@ def get_remote_url(action, repo_dir, task_vars, remote='origin'): task_vars=task_vars, ) if cmd_result.get('failed'): - raise AnsibleActionFail(f"Couldn't read the URL of remote '{remote}' in {repo_dir}", result=cmd_result) + raise AnsibleActionFail( + f"Couldn't read the URL of remote '{remote}' in {repo_dir}", + result=cmd_result, + ) return cmd_result['stdout'] @@ -62,17 +67,28 @@ def update_remote(action, repo_dir, remote, task_vars, accept_hostkey=False): cmd_result = action._execute_module( module_name='ansible.builtin.command', module_args=dict( - argv=['env', f'GIT_SSH_COMMAND={ssh_command}', 'git', 'remote', 'update', remote], + argv=[ + 'env', + f'GIT_SSH_COMMAND={ssh_command}', + 'git', + 'remote', + 'update', + remote, + ], chdir=repo_dir, ), task_vars=task_vars, ) if cmd_result.get('failed'): - raise AnsibleActionFail(f"Couldn't update remote '{remote}' for {repo_dir}", result=cmd_result) + raise AnsibleActionFail( + f"Couldn't update remote '{remote}' for {repo_dir}", result=cmd_result + ) def is_ancestor(action, repo_dir, remote, version, task_vars): - looks_like_hash = all(((c >= '0' and c <= '9') or (c >= 'a' and c <= 'f') for c in version)) + looks_like_hash = all( + ((c >= '0' and c <= '9') or (c >= 'a' and c <= 'f') for c in version) + ) remote_versions = [f'{remote}/{version}'] if looks_like_hash: @@ -93,4 +109,6 @@ def is_ancestor(action, repo_dir, remote, version, task_vars): else: return True - raise AnsibleActionFail(f"Couldn't deduce how the HEAD of {repo_dir} relates to remote version {remote}/{version}") + raise AnsibleActionFail( + f"Couldn't deduce how the HEAD of {repo_dir} relates to remote version {remote}/{version}" + ) -- cgit v1.3