Skip to content

Commit

Permalink
fixup! Refactor code to Python>=3.9 to pass pyupgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
martinhoyer committed May 20, 2024
1 parent 075b7e6 commit 60a1ce9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
3 changes: 1 addition & 2 deletions rtslib/alua.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
under the License.
'''

import six

from .node import CFSNode
from .utils import RTSLibALUANotSupportedError, RTSLibError, fread, fwrite
Expand Down Expand Up @@ -396,7 +395,7 @@ def setup(cls, storage_obj, alua_tpg, err_func): # noqa: ARG003 TODO
return

alua_tpg_obj = cls(storage_obj, name, alua_tpg['tg_pt_gp_id'])
for param, value in six.iteritems(alua_tpg):
for param, value in alua_tpg.items():
if param not in ('name', 'tg_pt_gp_id'):
try:
setattr(alua_tpg_obj, param, value)
Expand Down
6 changes: 2 additions & 4 deletions rtslib/fabric.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@
from functools import partial
from pathlib import Path

import six

from .node import CFSNode
from .target import Target
from .utils import (
Expand Down Expand Up @@ -330,7 +328,7 @@ def setup(self, fm, err_func):
'''
Setup fabricmodule with settings from fm dict.
'''
for name, value in six.iteritems(fm):
for name, value in fm.items():
if name != 'name':
try:
setattr(self, name, value)
Expand Down Expand Up @@ -546,7 +544,7 @@ def __new__(cls, name):

@classmethod
def all(cls):
for mod in six.itervalues(fabric_modules):
for mod in fabric_modules.values():
yield mod()

@classmethod
Expand Down
6 changes: 2 additions & 4 deletions rtslib/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
from functools import partial
from pathlib import Path

import six

from . import tcm
from .node import CFSNode
from .utils import (
Expand Down Expand Up @@ -447,7 +445,7 @@ def setup(cls, t_obj, tpg, err_func):
tpg_obj.enable = tpg.get('enable', True)
dict_remove(tpg, ('luns', 'portals', 'node_acls', 'tag',
'attributes', 'parameters', 'enable'))
for name, value in six.iteritems(tpg):
for name, value in tpg.items():
if value:
try:
setattr(tpg_obj, name, value)
Expand Down Expand Up @@ -1134,7 +1132,7 @@ def setup(cls, tpg_obj, acl, err_func):
MappedLUN.setup(tpg_obj, acl_obj, mlun, err_func)

dict_remove(acl, ('attributes', 'mapped_luns', 'node_wwn'))
for name, value in six.iteritems(acl):
for name, value in acl.items():
if value:
try:
setattr(acl_obj, name, value)
Expand Down
5 changes: 2 additions & 3 deletions rtslib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from pathlib import Path

import pyudev
import six

_CONTEXT = pyudev.Context()

Expand Down Expand Up @@ -492,14 +491,14 @@ def _set_auth_attr(self, value, attribute, ignore=False):
raise

def set_attributes(obj, attr_dict, err_func):
for name, value in six.iteritems(attr_dict):
for name, value in attr_dict.items():
try:
obj.set_attribute(name, value)
except RTSLibError as e:
err_func(str(e))

def set_parameters(obj, param_dict, err_func):
for name, value in six.iteritems(param_dict):
for name, value in param_dict.items():
try:
obj.set_parameter(name, value)
except RTSLibError as e:
Expand Down

0 comments on commit 60a1ce9

Please sign in to comment.