[2/3 blivet] Add method to set the default disklabel (#1078537)

Anne Mulhern amulhern at redhat.com
Thu Jun 19 13:05:53 UTC 2014





----- Original Message -----
> From: "Martin Kolman" <mkolman at redhat.com>
> To: "anaconda patch review" <anaconda-patches at lists.fedorahosted.org>
> Sent: Thursday, June 19, 2014 7:58:48 AM
> Subject: Re: [2/3 blivet] Add method to set the default disklabel (#1078537)
> 
> On Thu, 2014-06-19 at 07:47 -0400, Anne Mulhern wrote:
> > 
> > 
> > 
> > ----- Original Message -----
> > > From: "Brian C. Lane" <bcl at redhat.com>
> > > To: anaconda-patches at lists.fedorahosted.org
> > > Sent: Wednesday, June 18, 2014 7:27:04 PM
> > > Subject: [2/3 blivet] Add method to set the default disklabel (#1078537)
> > > 
> > > platform.setDefaultDiskLabel(label) will move the disklabel to the front
> > > of the list if it is supported on the current platform and return True.
> > > If it isn't supported it will return False and leave the list as is.
> > > ---
> > >  blivet/platform.py | 28 ++++++++++++++++++++++++----
> > >  1 file changed, 24 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/blivet/platform.py b/blivet/platform.py
> > > index 498d08c..058848a 100644
> > > --- a/blivet/platform.py
> > > +++ b/blivet/platform.py
> > > @@ -65,10 +65,10 @@ class Platform(object):
> > >          self.update_from_flags()
> > >  
> > >      def update_from_flags(self):
> > > -        if flags.gpt and "gpt" in self._disklabel_types:
> > > -            # move GPT to the top of the list
> > > -            self._disklabel_types.remove("gpt")
> > > -            self._disklabel_types.insert(0, "gpt")
> > > +        if flags.gpt:
> > > +            if not self.setDefaultDiskLabelType("gpt"):
> > > +                log.warn("GPT is not a supported disklabel on this
> > > platform.
> > > Using default "
> > > +                         "disklabel %s instead.",
> > > self.defaultDiskLabelType)
> > >  
> > >      def __call__(self):
> > >          return self
> > > @@ -83,6 +83,26 @@ class Platform(object):
> > >          """The default disklabel type for this architecture."""
> > >          return self.diskLabelTypes[0]
> > >  
> > > +    def setDefaultDiskLabelType(self, disklabel):
> > > +        """Make the disklabel the default
> > > +
> > > +           :param string disklabel: The disklabel type to set as default
> > 
> > If you use actual typename "str" above, you get a pretty little hyperlink
> > in the
> > generated html documents and so forth as appropriate. For "string", nothing
> > but plain old text.
> This sounds like a possible Sphinx RFE/bugreport to me.
> 

I realized there's an amusing problem.
1) str is actually a type name, as <type 'str'> whereas string is not, but
2) there is no documentation about the type to link to, so the link goes to the str() function
This is how the Python library documentation behaves as well as our blivet documentation.

This is probably why 
1) For :param you get the behavior I described
2) For :rtype: str does not get a link

The behavior is consistent for str, int, bool, all those builtin types.

But I still think we should use the actual type name in docs.
For forward compatibility considerations, in Python 3 docs,
there is a tiny entry for the str class, and the link makes more sense.

I've suggested to intersphinx that they put links in both :param and :rtype
positions for these builtin types.

> > 
> > > +           :returns: True if successful False if disklabel not supported
> > > +
> > > +           If the disklabel is not supported on the platform it will
> > > return
> > > +           False and make no change to the disklabel list.
> > > +
> > > +           If it is supported it will move it to the start of the list,
> > > +           making it the default.
> > > +        """
> > > +        if disklabel not in self._disklabel_types:
> > > +            return False
> > > +
> > > +        self._disklabel_types.remove(disklabel)
> > > +        self._disklabel_types.insert(0, disklabel)
> > > +        log.debug("Default disklabel has been set to %s", disklabel)
> > > +        return True
> > > +
> > >      @property
> > >      def bootStage1ConstraintDict(self):
> > >          d = {"device_types": self._boot_stage1_device_types,
> > > --
> > > 1.9.3
> > > 
> > > _______________________________________________
> > > anaconda-patches mailing list
> > > anaconda-patches at lists.fedorahosted.org
> > > https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> > > 
> > 
> > Otherwise, ack.
> > 
> > - mulhern
> > _______________________________________________
> > anaconda-patches mailing list
> > anaconda-patches at lists.fedorahosted.org
> > https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> 
> 
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> 

- mulhern


More information about the anaconda-patches mailing list