[anaconda:master 2/2] Make size_from_input() and size_from_entry() methods handier.

Anne Mulhern amulhern at redhat.com
Wed Oct 22 11:56:38 UTC 2014





----- Original Message -----
> From: "Vratislav Podzimek" <vpodzime at redhat.com>
> To: "anaconda patch review" <anaconda-patches at lists.fedorahosted.org>
> Sent: Wednesday, October 22, 2014 1:55:25 AM
> Subject: Re: [anaconda:master 2/2] Make size_from_input() and	size_from_entry() methods handier.
> 
> On Tue, 2014-10-21 at 10:06 -0400, mulhern wrote:
> > * In size_from_input(), do not round up to any lower bound, just get the
> > size. It's more general that way.
> > * Parameterize size_from_input() on default units.
> > * Parameterize size_from_entry() on a lower bound and on default units.
> > * Add method docstrings.
> > 
> > Should not change any observable behavior.
> > 
> > Signed-off-by: mulhern <amulhern at redhat.com>
> > ---
> >  pyanaconda/storage_utils.py                        | 22 ++++++----
> >  pyanaconda/ui/gui/spokes/custom.py                 | 14 +++++--
> >  .../ui/gui/spokes/lib/custom_storage_helpers.py    | 48
> >  ++++++++++++++++++++--
> >  3 files changed, 68 insertions(+), 16 deletions(-)
> > 
> > diff --git a/pyanaconda/storage_utils.py b/pyanaconda/storage_utils.py
> > index 7d26e78..4c35184 100644
> > --- a/pyanaconda/storage_utils.py
> > +++ b/pyanaconda/storage_utils.py
> > @@ -90,26 +90,30 @@ AUTOPART_DEVICE_TYPES = {AUTOPART_TYPE_LVM:
> > DEVICE_TYPE_LVM,
> >  NAMED_DEVICE_TYPES = (DEVICE_TYPE_BTRFS, DEVICE_TYPE_LVM, DEVICE_TYPE_MD,
> >  DEVICE_TYPE_LVM_THINP)
> >  CONTAINER_DEVICE_TYPES = (DEVICE_TYPE_LVM, DEVICE_TYPE_BTRFS,
> >  DEVICE_TYPE_LVM_THINP)
> >  
> > -def size_from_input(input_str):
> > -    """Get size from user's input"""
> > +def size_from_input(input_str, units=None):
> I think 'units' should default to 'MiB' as that's what e.g. pykickstart
> does. Otherwise the SIZE_UNITS_DEFAULT constant should be moved to
> pyanaconda/constants.py so that it can be used in other places as well
> enforcing consistency between those places.
> 
> --
> Vratislav Podzimek
> 
> Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
> 
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> 

OK, SIZE_UNITS_DEFAULT moved out to pyanaconda/constants.py.

- mulhern


More information about the anaconda-patches mailing list