[PATCHv2] Read /etc/os-release to get product title (#1000426)

Brian C. Lane bcl at redhat.com
Fri Sep 6 17:09:47 UTC 2013


On Fri, Sep 06, 2013 at 09:04:04AM +0200, Vratislav Podzimek wrote:
> On Thu, 2013-09-05 at 14:22 -0700, Brian C. Lane wrote:
> > > +def product_title():
> > > +    """
> > > +    Get product title.
> > > +
> > > +    :return: product title
> > > +    :rtype: str
> > > +
> > > +    """
> > > +
> > > +    try:
> > > +        with open(RELEASE_STRING_FILE, "r") as fobj:
> > > +            for line in fobj:
> > > +                (key, _eq, value) = line.strip().partition("=")
> > > +                if not key or not _eq or not value:
> > > +                    continue
> > > +                if key == "PRETTY_NAME":
> > > +                    return value.strip('"')
> > > +    except IOError:
> > > +        return ""
> > 
> > It says the return type is str, so it should return "" at the end
> > instead of dropping out with None. Maybe something like:
> > 
> > except IOError:
> >     pass
> > finally:
> >     return ""
> I moved the 'return ""' statement out of the finally block because
> pylint pointed out an interesting thing -- return statement in the
> finally block swallows exceptions! It might not be a problem in this
> case, but it's better not to play such game. :)

Good point, +1 to pylint :)

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 482 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/anaconda-patches/attachments/20130906/d154d1d0/attachment-0001.sig>


More information about the anaconda-patches mailing list