mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 21:03:30 -07:00
- Made PrettyPrinter function more robust (one can pass it sizes in bytes)
This commit is contained in:
parent
efed943366
commit
3f9b74430a
1 changed files with 5 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
|||
#VERSION: 1.32
|
||||
#VERSION: 1.33
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
|
@ -48,12 +48,15 @@ def anySizeToBytes(size_string):
|
|||
try:
|
||||
size = size_string.strip()
|
||||
unit = ''.join([c for c in size if c.isalpha()])
|
||||
size = size[:-len(unit)]
|
||||
if len(unit) > 0:
|
||||
size = size[:-len(unit)]
|
||||
except:
|
||||
return -1
|
||||
if len(size) == 0:
|
||||
return -1
|
||||
size = float(size)
|
||||
if len(unit) == 0:
|
||||
return int(size)
|
||||
short_unit = unit.upper()[0]
|
||||
|
||||
# convert
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue