From 3f9b74430a45c96d0bd72e97fa880a904c7e63df Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Fri, 27 Nov 2009 23:01:16 +0000 Subject: [PATCH] - Made PrettyPrinter function more robust (one can pass it sizes in bytes) --- src/search_engine/novaprinter.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/search_engine/novaprinter.py b/src/search_engine/novaprinter.py index 5650e58a2..4811b39cd 100644 --- a/src/search_engine/novaprinter.py +++ b/src/search_engine/novaprinter.py @@ -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