[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [PATCH 3/9] Use new functions for conversion between size and sector count.



> > > +def sectorsToSize(sectors, sectorSize):
> > > +    """ Convert length in sectors to size in MB.
> > > +
> > > +        Arguments:
> > > +
> > > +            sectors     -   sector count
> > > +            sectorSize  -   sector size for the device, in bytes
> > > +    """
> > > +    return (sectors * sectorSize) / (1024.0 * 1024.0)

parted.Device has a getSize() method that already covers this one.  You
can even pass it a unit to return the size in, MB by default.

> > > +def sizeToSectors(size, sectorSize):
> > > +    """ Convert size in MB to length in sectors.
> > > +
> > > +        Arguments:
> > > +
> > > +            size        -   size in MB
> > > +            sectorSize  -   sector size for the device, in bytes
> > > +    """
> > > +    return (size * 1024.0 * 1024.0) / sectorSize

We don't have an equivalent method for this, though that could easily be
added.

- Chris


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]