@@ -51,31 +51,33 @@ def wrapper(*args: Any, **kwargs: Any) -> T:
51
51
return wrapper
52
52
return outer
53
53
54
- def classattributes (default_attr ,more_allowed_attr ):
55
- """ class __init__decorator
54
+
55
+ def classattributes (default_attr , more_allowed_attr ):
56
+ """ class __init__decorator
56
57
Parses kwargs attributes, for optional arguments uses default values,
57
58
if not provided with kwargs
58
59
Usage:
59
60
1st arg is a dict of attributes with default values
60
61
2nd arg is a list of additional allowed attributes which may be instantiated or not
61
62
"""
62
63
def class_decorator (cls ):
63
- def new_init (self ,** kwargs ):
64
+ def new_init (self , ** kwargs ):
64
65
allowed_attr = list (default_attr .keys ()) + more_allowed_attr
65
- default_attr_to_update = copy .deepcopy (default_attr )
66
+ default_attr_to_update = copy .deepcopy (default_attr )
66
67
default_attr_to_update .update (kwargs )
67
- self .__dict__ .update ((k ,v ) for k ,v in default_attr_to_update .items () if k in allowed_attr )
68
+ self .__dict__ .update ((k , v ) for k , v in default_attr_to_update .items () if k in allowed_attr )
68
69
cls .__init__ = new_init
69
70
return cls
70
71
return class_decorator
71
72
73
+
72
74
def getTimeMultiplier (timeunit ):
73
- ''' Translate OpenTSDB time units, ignoring ms (milliseconds)'''
74
- return {
75
+ """ Translate OpenTSDB time units, ignoring ms (milliseconds) """
76
+ return {
75
77
's' : 1 ,
76
78
'm' : 60 ,
77
79
'h' : 3600 ,
78
80
'd' : 86400 ,
79
81
'w' : 604800 ,
80
82
'n' : 2628000 ,
81
- 'y' : 31536000 , }.get (timeunit , - 1 )
83
+ 'y' : 31536000 , }.get (timeunit , - 1 )
0 commit comments