/var/opt/nydus/ops/customer_local_ops/util
NameSizeModeActions
__pycache__/-0755rm
compat.py16630644editdlrm
constants.py13030644editdlrm
encryptor.py114450644editdlrm
execute.py199630644editdlrm
helpers.py24120644editdlrm
retry.py21440644editdlrm
sizes.py125400644editdlrm
__init__.py16250644editdlrm
Edit: /var/opt/nydus/ops/customer_local_ops/util/compat.py (1663B)
# -*- coding: utf-8 -*- """ Compatibility utilities for supporting multiple Python versions. This module provides utilities and workarounds to ensure compatibility across Python 3.5 through Python 3.12, with special attention to Windows-specific issues. """ import sys import platform import asyncio # Python version checks PY35 = sys.version_info[:2] == (3, 5) PY36 = sys.version_info[:2] == (3, 6) PY37 = sys.version_info[:2] == (3, 7) PY38 = sys.version_info[:2] == (3, 8) PY38_PLUS = sys.version_info[:2] >= (3, 8) # Platform checks IS_WINDOWS = platform.system() == 'Windows' def setup_windows_event_loop(): """ Set up the appropriate event loop for Windows in Python 3.8+. Python 3.8 changed the default event loop on Windows from SelectorEventLoop to ProactorEventLoop. This can cause compatibility issues with some libraries. This function ensures we use the SelectorEventLoop for consistency. """ if IS_WINDOWS and PY38_PLUS: # Set Windows event loop policy to use SelectorEventLoop asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) def format_string(template, *args, **kwargs): """ Provide a consistent string formatting method across Python versions. This is a wrapper around str.format() to ensure consistent behavior and provide a migration path from f-strings for Python 3.5 compatibility. Args: template: The string template with {} placeholders *args: Positional arguments for formatting **kwargs: Keyword arguments for formatting Returns: Formatted string """ return template.format(*args, **kwargs)