On 09/04/2010 04:56 AM, dcantrell@xxxxxxxxxx wrote:
From: David Cantrell<dcantrell@xxxxxxxxxx> Created a new class called Size under the storage module. It can represent sizes where we have traditionally used megabytes. The size is stored as bytes in the object, but can convert to any other type unit supported by the class. The class also has the humanReadable() method, which will output the size in a human readable format to a specified number of decimal places, or fewer if that makes sense in the given situation. The initialization method also accepts a number of bytes or a string specification for the size, such as "32 GB" or "640 kb". --- pyanaconda/storage/size.py | 230 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 230 insertions(+), 0 deletions(-) create mode 100644 pyanaconda/storage/size.py
Ack from me, with a few notes:
+ def _makeSpecs(self, prefix, abbr): + """ Internal method used to generate a list of specifiers. """ + specs = [] + + if prefix: + specs.append("%sbytes" % prefix.lower())
Are going to be passing user input through this method at some point? Then you could also add:
specs.append("%sbyte" % prefix.lower()) i.e. singular form so they can say "1 Megabyte".
+ + def humanReadable(self, places=2):
Maybe this method should be called __str__ ? Or let's just define __str__ that calls self.humanReadable(places=2).
Ales _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list