@@ -67,7 +67,7 @@ def parse_unit(cls, value):
6767 :return: a tuple of the size value as int and the SizeCalc.UNIT
6868 :rtype: (int, int)
6969 """
70- m = re .match ('(\d+)\s*(\D*)' , value )
70+ m = re .match (r '(\d+)\s*(\D*)' , value )
7171
7272 size = None
7373 if m :
@@ -108,15 +108,16 @@ def convert(cls, size, unit_in, unit_out):
108108 a size value given in the scale unit of unit_out
109109 (e.g. convert from decimal megabytes to binary gigabytes, ...)
110110
111- @ param size: numeric size value
112- @ param unit_in: scale unit selector of the size parameter
113- @ param unit_out: scale unit selector of the return value
114- @ return: size value converted to the scale unit of unit_out
111+ : param size: numeric size value
112+ : param unit_in: scale unit selector of the size parameter
113+ : param unit_out: scale unit selector of the return value
114+ : return: size value converted to the scale unit of unit_out
115115 truncated to an integer value
116+ :rtype: int
116117 """
117118 fac_in = ((unit_in & 0xffffff00 ) >> 8 ) ** (unit_in & 0xff )
118119 div_out = ((unit_out & 0xffffff00 ) >> 8 ) ** (unit_out & 0xff )
119- return ( size * fac_in // div_out )
120+ return size * fac_in // div_out
120121
121122 @classmethod
122123 def convert_round_up (cls , size , unit_in , unit_out ):
@@ -133,10 +134,11 @@ def convert_round_up(cls, size, unit_in, unit_out):
133134 returns 97,657 binary kilobytes (kiB), which equals 100 million
134135 plus 768 bytes and therefore is large enough to contain 100 megabytes)
135136
136- @param size: numeric size value
137- @param unit_in: scale unit selector of the size parameter
138- @param unit_out: scale unit selector of the return value
139- @return: size value converted to the scale unit of unit_out
137+ :param size: numeric size value
138+ :param unit_in: scale unit selector of the size parameter
139+ :param unit_out: scale unit selector of the return value
140+ :return: size value converted to the scale unit of unit_out
141+ :rtype: int
140142 """
141143 fac_in = ((unit_in & 0xffffff00 ) >> 8 ) ** (unit_in & 0xff )
142144 div_out = ((unit_out & 0xffffff00 ) >> 8 ) ** (unit_out & 0xff )
@@ -151,6 +153,10 @@ def convert_round_up(cls, size, unit_in, unit_out):
151153 def approximate_size_string (cls , size_kib ):
152154 """
153155 Produce human readable size information as a string
156+
157+ :param int size_kib: size in kibi byte
158+ :return: human readable size string
159+ :rtype: str
154160 """
155161 units = [
156162 "KiB" ,
@@ -176,7 +182,7 @@ def approximate_size_string(cls, size_kib):
176182 size_str = None
177183 if size_kib % magnitude != 0 :
178184 size_unit = float (size_kib ) / magnitude
179- size_loc = locale .format ('%3.2f' , size_unit , grouping = True )
185+ size_loc = locale .format_string ('%3.2f' , size_unit , grouping = True )
180186 size_str = "%s %s" % (size_loc , units [index ])
181187 else :
182188 size_unit = size_kib / magnitude
0 commit comments