From 1eafba8ae64dcf29fe435bd6c0fad1bd18332aa7 Mon Sep 17 00:00:00 2001 From: Martin Hoyer Date: Wed, 11 Sep 2024 14:35:32 +0200 Subject: [PATCH] Add rtslib_fb import compability --- .gitignore | 5 ++++- .pre-commit-config.yaml | 2 +- rtslib/utils.py | 2 +- rtslib_fb.py | 21 +++++++++++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 rtslib_fb.py diff --git a/.gitignore b/.gitignore index d22c431..d514c60 100644 --- a/.gitignore +++ b/.gitignore @@ -13,10 +13,13 @@ debian/rtslib-doc.debianebhelper.log debian/rtslib-doc.substvars debian/rtslib-doc/ debian/tmp/ -dist/* +dist/ doc/* *.pyc debian/rtslib-doc.debhelper.log venv/ +.venv/ .idea *egg-info/ +.mypy_cache/ +.ruff_cache/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c2b5c82..209c747 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.4.4 + rev: v0.6.4 hooks: - id: ruff args: [--fix] diff --git a/rtslib/utils.py b/rtslib/utils.py index 692d578..baebc04 100644 --- a/rtslib/utils.py +++ b/rtslib/utils.py @@ -415,7 +415,7 @@ def modprobe(module): import kmod.error import kmod.Kmod except ImportError: - out = subprocess.run(f"modprobe {module}", shell=True, capture_output=True, check=False) # noqa: S602, S607 + out = subprocess.run(f"modprobe {module}", shell=True, capture_output=True, check=False) # noqa: S602 if out.returncode != 0: raise RTSLibError(out.stderr.decode().rstrip()) return diff --git a/rtslib_fb.py b/rtslib_fb.py new file mode 100644 index 0000000..2b985fe --- /dev/null +++ b/rtslib_fb.py @@ -0,0 +1,21 @@ +""" +rtslib_fb.py - Backwards compatibility module for rtslib + +This module provides backwards compatibility for code that imports 'rtslib_fb'. +It re-exports all public names from the 'rtslib' module. + +Usage: + from rtslib_fb import RTSRoot, Target, TPG # etc. + +Note: This compatibility layer may be deprecated in future versions. +Please consider updating your imports to use 'rtslib' directly. +""" + +import rtslib +from rtslib import * # noqa: F403 + +# Explicitly import and re-export submodules +from rtslib import alua, fabric, node, root, target, tcm, utils # noqa: F401 + +# Re-export all public names from rtslib +__all__ = rtslib.__all__