Exemple #1
0
def selectorFromDevice(device, selector=None, mountpoint=""):
    """Create a MountpointSelector from a Device object template.  This
       method should be used whenever constructing a new selector, or when
       setting a bunch of attributes on an existing selector.  For just
       changing the name or size, it's probably fine to do it by hand.

       This method returns the selector created.

       If given a selector parameter, attributes will be set on that object
       instead of creating a new one.  The optional mountpoint parameter
       allows for specifying the mountpoint if it cannot be determined from
       the device (like for a Root specifying an existing installation).
    """
    if hasattr(device.format,
               "mountpoint") and device.format.mountpoint is not None:
        mp = device.format.mountpoint
    elif mountpoint:
        mp = mountpoint
    elif device.format.name:
        mp = device.format.name
    else:
        mp = _("Unknown")

    if not selector:
        selector = MountpointSelector(device.name, str(device.size), mp)
        selector._root = None
    else:
        selector.props.name = device.name
        selector.props.size = str(device.size)
        selector.props.mountpoint = mp

    selector._device = device
    return selector
Exemple #2
0
def selectorFromDevice(device, selector=None, mountpoint=""):
    """Create a MountpointSelector from a Device object template.  This
       method should be used whenever constructing a new selector, or when
       setting a bunch of attributes on an existing selector.  For just
       changing the name or size, it's probably fine to do it by hand.

       This method returns the selector created.

       If given a selector parameter, attributes will be set on that object
       instead of creating a new one.  The optional mountpoint parameter
       allows for specifying the mountpoint if it cannot be determined from
       the device (like for a Root specifying an existing installation).
    """
    if hasattr(device.format, "mountpoint") and device.format.mountpoint is not None:
        mp = device.format.mountpoint
    elif mountpoint:
        mp = mountpoint
    elif device.format.name:
        mp = device.format.name
    else:
        mp = _("Unknown")

    size = Size(en_spec="%f MB" % device.size)

    if not selector:
        selector = MountpointSelector(device.name, str(size).upper(), mp)
        selector._root = None
    else:
        selector.props.name = device.name
        selector.props.size = str(size).upper()
        selector.props.mountpoint = mp

    selector._device = device
    return selector
def newSelectorFromDevice(device, mountpoint=""):
    selector = MountpointSelector(device.name, str(device.size))
    selector._root = None
    updateSelectorFromDevice(selector, device, mountpoint)

    return selector
Exemple #4
0
def new_selector_from_device(device, mountpoint=""):
    selector = MountpointSelector(device.name, str(device.size))
    selector._root = None
    update_selector_from_device(selector, device, mountpoint)

    return selector