[blivet master 2/3] Force __str__ to return str.

Vratislav Podzimek vpodzime at redhat.com
Thu Oct 16 07:22:06 UTC 2014


On Wed, 2014-10-15 at 16:05 -0400, David Shea wrote:
> On 10/15/2014 04:00 PM, Anne Mulhern wrote:
> >
> >
> >
> > ----- Original Message -----
> >> From: "David Shea" <dshea at redhat.com>
> >> To: anaconda-patches at lists.fedorahosted.org
> >> Sent: Wednesday, October 15, 2014 11:32:38 AM
> >> Subject: [blivet master 2/3] Force __str__ to return str.
> >>
> >> Explicitly cast __str__ results to str any time there is an ambiguity
> >> in type the result string may be. Add __unicode__ methods so that when
> >> these objects are converted to unicode they don't need to go through
> >> encoding conversions.
> >> ---
> >>   blivet/deviceaction.py   | 10 +++++++++-
> >>   blivet/devices/device.py |  9 ++++++++-
> >>   blivet/partitioning.py   | 19 +++++++++++++++++--
> >>   blivet/partspec.py       | 11 ++++++++++-
> >>   blivet/size.py           | 10 +++++++++-
> >>   blivet/util.py           | 48
> >>   ++++++++++++++++++++++++++++++++++++++++++++++--
> >>   blivet/zfcp.py           | 10 +++++++++-
> >>   7 files changed, 108 insertions(+), 9 deletions(-)
> >>
> > <-- SNIP -->
> >
> >>   
> >> diff --git a/blivet/util.py b/blivet/util.py
> >> index 90b8515..fa62261 100644
> >> --- a/blivet/util.py
> >> +++ b/blivet/util.py
> >> @@ -14,8 +14,6 @@ from contextlib import contextmanager
> >>   
> >>   import six
> >>   
> >> -from .size import Size
> >> -
> >>   import logging
> >>   log = logging.getLogger("blivet")
> >>   program_log = logging.getLogger("program")
> >> @@ -144,6 +142,8 @@ def total_memory():
> >>   
> >>           :rtype: :class:`~.size.Size`
> >>       """
> >> +    from .size import Size
> >> +
> >>       lines = open("/proc/meminfo").readlines()
> >>       for line in lines:
> >>           if line.startswith("MemTotal:"):
> >> @@ -324,6 +324,8 @@ def numeric_type(num):
> >>           Return the number if the type is sensible or raise ValueError
> >>           if not.
> >>       """
> >> +    from .size import Size
> >> +
> >>       if num is None:
> >>           num = 0
> >>       elif not isinstance(num, (six.integer_types, float, Size, Decimal)):
> >> @@ -382,6 +384,48 @@ def canonicalize_UUID(a_uuid):
> >>       """
> >>       return str(uuid.UUID(a_uuid.replace(':', '')))
> > When I do an import with method scope instead of file scope,
> > I usually am asked to add a comment at the import site explaining why.
> 
> Fair enough. Added:
> # import locally to avoid a cycle with size importing util
> above each.
That answers my only question. ACK.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list