[blivet:master+? 3/5] Rewrite _parseSpec() and convertTo()

Anne Mulhern amulhern at redhat.com
Wed Oct 29 17:13:47 UTC 2014





----- Original Message -----
> From: "Vratislav Podzimek" <vpodzime at redhat.com>
> To: "anaconda patch review" <anaconda-patches at lists.fedorahosted.org>
> Sent: Wednesday, October 29, 2014 9:03:35 AM
> Subject: Re: [blivet:master+? 3/5] Rewrite _parseSpec() and convertTo()
> 
> On Mon, 2014-10-27 at 08:07 -0400, mulhern wrote:
> > This fixes a bug where most English specifiers would not be parsed
> > unless the locale was a lot like English; after failing to be parsed
> > in the English section, they still got their chance to be parsed in
> > the locale-specific section, and if it was close enough, as it usually
> > is for me, it would be parsed there.
> > 
> > Add a method, _parseUnits(), which handles the parsing of the units
> > part of the spec. Abstract this for both translated and non-translated.
> > If there is no exact match for the units, see if the units are a prefix
> > of a binary abbreviation.
> > 
> > Remove _makeSpecs() entirely, and redistribute its functionality between
> > new methods _parseUnits() and _makeSpec().
> > 
> > Rewrite convertTo() so that it uses newly introduced _parseUnits() not
> > newly removed _makeSpecs() and make it work with translated specs as well
> > as untranslated.
> > Thereby fix a small bug where the spec was lower-cased as if it were locale
> > specific, but the prefixes to match against were untranslated.
> > Change default to "", which means bytes, just like "b".
> > These changes emphasises that _parseSpec() and convertTo() should agree on
> > what a spec means.
> > Also, just accept the default for calls to convertTo() in size.
> > 
> > Remove now useless imports, constants, functions.
> > 
> > Update tests appropriately.
> > 
> > Signed-off-by: mulhern <amulhern at redhat.com>
> > ---
> >  blivet/size.py     | 180
> >  ++++++++++++++++++++++++++---------------------------
> >  tests/size_test.py |   4 +-
> >  2 files changed, 89 insertions(+), 95 deletions(-)
> > 
> > diff --git a/blivet/size.py b/blivet/size.py
> > index d0eecb6..c46ac69 100644
> > --- a/blivet/size.py
> > +++ b/blivet/size.py
> > @@ -19,7 +19,6 @@
> >  #
> >  # Red Hat Author(s): David Cantrell <dcantrell at redhat.com>
> >  
> > -import itertools
> >  import re
> >  import string
> >  import locale
> > @@ -41,6 +40,9 @@ _Prefix = namedtuple("Prefix", ["factor", "prefix",
> > "abbr"])
> >  _DECIMAL_FACTOR = 10 ** 3
> >  _BINARY_FACTOR = 2 ** 10
> >  
> > +_BYTES_SYMBOL = N_(b"B")
> > +_BYTES_WORDS = [N_(b"bytes"), N_(b"byte")]
> This could be a tuple.
> 
> Otherwise this together with the other patches from the set look good to
> me.
> 
> --
> 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
> 

Done.

- mulhern


More information about the anaconda-patches mailing list