@@ -59,6 +59,31 @@ class Format:
5959 ],
6060 }
6161
62+ casing_shorter = {
63+ 1024 : [
64+ '' ,
65+ 'K' ,
66+ 'M' ,
67+ 'G' ,
68+ 'T' ,
69+ 'P' ,
70+ 'E' ,
71+ 'Z' ,
72+ 'Y' ,
73+ ],
74+ 1000 : [
75+ '' ,
76+ 'k' ,
77+ 'm' ,
78+ 'g' ,
79+ 't' ,
80+ 'p' ,
81+ 'e' ,
82+ 'z' ,
83+ 'y' ,
84+ ],
85+ }
86+
6287 casing_verbose = {
6388 1024 : [
6489 (' byte' , ' bytes' ),
@@ -284,26 +309,27 @@ def __format__(self, fmt):
284309 '''
285310 format specification:
286311 format type: [hH][size_format][^exponent]
287- size_format: c | cs | cv | e | ev | s | sv
288- exponent: integer
312+ size_format: c | cs | css | cv | e | ev | s | sv
313+ exponent: integer
289314
290315 base is required sometimes if no exponent is specified
291316 always specifying the base gives a shorter format specification
292317 '''
293318 # is it an empty format or not a special format for the size class
294- matches = re .search (r'([hH])(?:(c|cs|cv|e|ev|s|sv)?(?:\^(\d+))?)?$' , fmt )
319+ matches = re .search (r'([hH])(?:(c|cs|css| cv|e|ev|s|sv)?(?:\^(\d+))?)?$' , fmt )
295320 if not matches :
296321 return int (self ).__format__ (fmt )
297322 fmt_type , size_fmt , exponent = matches .groups ()
298323 size_fmt = {
299- None : Format .casing ,
300- 'c' : Format .casing ,
301- 'cs' : Format .casing_short ,
302- 'cv' : Format .casing_verbose ,
303- 'e' : Format .iec ,
304- 'ev' : Format .iec_verbose ,
305- 's' : Format .si ,
306- 'sv' : Format .si_verbose ,
324+ None : Format .casing ,
325+ 'c' : Format .casing ,
326+ 'cs' : Format .casing_short ,
327+ 'css' : Format .casing_shorter ,
328+ 'cv' : Format .casing_verbose ,
329+ 'e' : Format .iec ,
330+ 'ev' : Format .iec_verbose ,
331+ 's' : Format .si ,
332+ 'sv' : Format .si_verbose ,
307333 }[size_fmt ]
308334 if fmt_type == 'h' :
309335 base = 1000
0 commit comments