Skip to content

Commit

Permalink
fix por Format attributes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
ralequi committed Mar 22, 2023
1 parent 3102f15 commit 46dba00
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
32 changes: 32 additions & 0 deletions pystorcli2/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,38 @@ def wrapper(*args, **kwargs):
return wrapper


def upper(func):
"""Decorator to upper returned function string.
Args:
func (func): function
Returns:
str: upper output of func
"""
def wrapper(*args, **kwargs):
"""func effective wrapper
"""
return func(*args, **kwargs).upper()
return wrapper


def strip(func):
"""Decorator to strip returned function string. It will be stripped both sides.
Args:
func (func): function
Returns:
str: stripped output of func
"""
def wrapper(*args, **kwargs):
"""func effective wrapper
"""
return func(*args, **kwargs).strip()
return wrapper


def stringify(func):
"""Decorator to convert obj to string.
Expand Down
15 changes: 9 additions & 6 deletions pystorcli2/drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def temperature(self):
return self._resposne_state['Drive Temperature'].split('C')[0].lstrip()

@property
@common.lower
@common.upper
def smart_alert(self):
"""(str): S.M.A.R.T alert flag on drive
"""
Expand Down Expand Up @@ -321,7 +321,7 @@ def size(self):
return self._response_properties(self._run(args))['Size']

@property
@common.lower
@common.upper
def interface(self):
"""(str): SATA / SAS
"""
Expand All @@ -331,7 +331,7 @@ def interface(self):
return self._response_properties(self._run(args))['Intf']

@property
@common.lower
@common.upper
def medium(self):
"""(str): SSD / HDD
"""
Expand All @@ -341,7 +341,8 @@ def medium(self):
return self._response_properties(self._run(args))['Med']

@property
@common.lower
@common.upper
@common.strip
def model(self):
"""(str): drive model informations
"""
Expand All @@ -351,6 +352,8 @@ def model(self):
return self._response_properties(self._run(args))['Model']

@property
@common.upper
@common.strip
def serial(self):
"""(str): drive serial number
"""
Expand All @@ -361,7 +364,7 @@ def serial(self):
return self._response_attributes(self._run(args))['SN']

@property
@common.lower
@common.upper
def wwn(self):
"""(str): drive wwn
"""
Expand All @@ -372,7 +375,7 @@ def wwn(self):
return self._response_attributes(self._run(args))['WWN']

@property
@common.lower
@common.upper
def firmware(self):
"""(str): drive firmware version
"""
Expand Down

0 comments on commit 46dba00

Please sign in to comment.