1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-05-04 01:13:00 +00:00

Reformat everything.

This commit is contained in:
Felix Fontein 2025-11-01 12:08:41 +01:00
parent 3f2213791a
commit 340ff8586d
1008 changed files with 61301 additions and 58309 deletions

View file

@ -9,6 +9,7 @@ from ansible.module_utils.common.collections import is_string
try:
from zlib import crc32
HAS_ZLIB = True
except ImportError:
HAS_ZLIB = False
@ -45,17 +46,17 @@ _value:
def crc32s(value):
if not is_string(value):
raise AnsibleFilterError(f'Invalid value type ({type(value)}) for crc32 ({value!r})')
raise AnsibleFilterError(f"Invalid value type ({type(value)}) for crc32 ({value!r})")
if not HAS_ZLIB:
raise AnsibleFilterError('Failed to import zlib module')
raise AnsibleFilterError("Failed to import zlib module")
data = to_bytes(value, errors='surrogate_or_strict')
return f"{crc32(data) & 0xffffffff:x}"
data = to_bytes(value, errors="surrogate_or_strict")
return f"{crc32(data) & 0xFFFFFFFF:x}"
class FilterModule:
def filters(self):
return {
'crc32': crc32s,
"crc32": crc32s,
}