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

Vratislav Podzimek vpodzime at redhat.com
Wed Oct 22 05:55:25 UTC 2014


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



More information about the anaconda-patches mailing list