Esempio n. 1
0
        if isinstance(other, six.integer_types):
            return ByteSize.Size.div_int(self, other)
        else:
            return Decimal(ByteSize.Size.true_div(self, other))

    def __truediv__(self, other):
        if isinstance(other, six.integer_types):
            return Decimal(ByteSize.Size.true_div_int(self, other))

        return Decimal(ByteSize.Size.true_div(self, other))

    def __floordiv__(self, other):
        if isinstance(other, six.integer_types):
            return ByteSize.Size.div_int(self, other)

        return ByteSize.Size.div(self, other)

    def __mod__(self, other):
        return ByteSize.Size.mod(self, other)

    def __repr__(self):
        return "Size (%s)" % self.human_readable(ByteSize.Bunit.B, -1, False)

    def __str__(self):
        return self.human_readable()


Size = override(Size)
__all__.append("Size")
Esempio n. 2
0
Vips.Argument = Argument

class Operation(Vips.Operation):

    # find all the args for this op, sort into priority order
    # remember to ignore deprecated ones
    def get_args(self):
        args = [Argument(self, x) for x in self.props]
        args = [y for y in args 
                if not y.flags & Vips.ArgumentFlags.DEPRECATED]
        args.sort(key = lambda x: x.priority)

        return args

Operation = override(Operation)
__all__.append('Operation')

# search a list recursively for a Vips.Image object
def find_image(x):
    if isinstance(x, Vips.Image):
        return x
    if isinstance(x, list):
        for i in x:
            y = find_image(i)
            if y is not None:
                return y
    return None

def _call_base(name, required, optional, self = None, option_string = None):
    logging.debug('_call_base name=%s, required=%s optional=%s' % 
Esempio n. 3
0
            return self.get_object()
        elif gtype == TYPE_UNICHAR:
            return self.get_uint()
        elif gtype == TYPE_GTYPE:
            return self.get_gtype()
        elif gtype == TYPE_VARIANT:
            return self.get_variant()
        elif gtype == TYPE_PYOBJECT:
            pass
        else:
            return None

    def __repr__(self):
        return '<Value (%s) %s>' % (self.g_type.name, self.get_value())

Value = override(Value)
__all__.append('Value')


def type_from_name(name):
    type_ = GObjectModule.type_from_name(name)
    if type_ == TYPE_INVALID:
        raise RuntimeError('unknown type name: %s' % name)
    return type_

__all__.append('type_from_name')


def type_parent(type_):
    parent = GObjectModule.type_parent(type_)
    if parent == TYPE_INVALID:
Esempio n. 4
0
The gi import machinery sweeps usr/lib/python*/dist-packages/gi/overrides for file
matching the module name at the time of execution.

This file needs to be in both python2 and python3 overrides locations.

"""

XApp = modules['XApp']._introspection_module

__all__ = []


class GtkWindow(XApp.GtkWindow):
    pass


class GtkButton(XApp.IconChooserButton):
    pass


class GtkBin(XApp.StackSidebar):
    pass


GtkWindow = override(GtkWindow)
GtkButton = override(GtkButton)
GtkBin = override(GtkBin)
__all__.append('GtkWindow')
__all__.append('GtkButton')
__all__.append('GtkBin')
Esempio n. 5
0
class ScopeResult(Unity.ScopeResult):
    @staticmethod
    def create(*args, **kwargs):
        if len(kwargs) > 0:
            result = kwargs_to_result_variant(**kwargs)
            return Unity.ScopeResult.create_from_variant(result)
        return Unity.ScopeResult.create(*args)


class SearchContext(Unity.SearchContext):
    @staticmethod
    def create(search_query, search_type, filter_state, metadata_dict, result_set, cancellable):
        context = Unity.SearchContext.create(search_query, search_type, filter_state, None, result_set, cancellable)
        if metadata_dict and len(metadata_dict) > 0:
            metadata_variant = dict_to_variant(metadata_dict)
            context.set_search_metadata(Unity.SearchMetadata.create_from_variant(metadata_variant))

        return context


ScopeSearchBase = override(ScopeSearchBase)
__all__.append("ScopeSearchBase")
ResultPreviewer = override(ResultPreviewer)
__all__.append("ResultPreviewer")
ResultSet = override(ResultSet)
__all__.append("ResultSet")
ScopeResult = override(ScopeResult)
__all__.append("ScopeResult")
SearchContext = override(SearchContext)
__all__.append("SearchContext")
Esempio n. 6
0
    "part": BlockDev.Plugin.PART,
    "fs": BlockDev.Plugin.FS,
    "s390": BlockDev.Plugin.S390,
    "nvdimm": BlockDev.Plugin.NVDIMM,
    "vdo": BlockDev.Plugin.VDO,
}


class ExtraArg(BlockDev.ExtraArg):
    def __new__(cls, opt, val=""):
        ret = BlockDev.ExtraArg.new(opt, val)
        ret.__class__ = cls
        return ret


ExtraArg = override(ExtraArg)
__all__.append("ExtraArg")


def _get_extra(extra, kwargs, cmd_extra=True):
    # pylint: disable=no-member
    # pylint doesn't really get how ExtraArg with overrides work
    if extra:
        if isinstance(extra, dict):
            ea = [ExtraArg.new(key, val) for key, val in extra.items()]
        elif isinstance(extra, list) and all(
                isinstance(arg, BlockDev.ExtraArg) for arg in extra):
            ea = extra
        else:
            msg = "extra arguments can only be given as a list of ExtraArg items or a as a dict"
            raise ValueError(msg)
Esempio n. 7
0
    def device(self):
        return self._device

    @device.setter
    def device(self, device):
        self._device = device

    @property
    def root(self):
        return self._root

    @root.setter
    def root(self, dev):
        self._root = dev

MountpointSelector = override(MountpointSelector)
__all__.append('MountpointSelector')

class SpokeSelector(Anaconda.SpokeSelector):
    def __init__(self, title=None, icon=None, status=None):
        Anaconda.SpokeSelector.__init__(self)

        if title:
            self.set_property("title", title)

        if icon:
            self.set_property("icon", icon)

        if status:
            self.set_property("status", status)
Esempio n. 8
0
    def __iter__ (self):
        itr = self.get_first_iter ()
        last = self.get_last_iter ()
        while itr != last:
            yield self.get_row(itr)
            itr = self.next(itr)
        raise StopIteration
    
    def __len__ (self):
        return self.get_n_rows()
        
        
class ModelIter(Dee.ModelIter):

    def __init__(self):
        Dee.ModelIter.__init__(self)

    def __eq__ (self, other):
        if not isinstance (other, ModelIter):
            return False
        return repr(self) == repr(other)



Model = override(Model)
__all__.append('Model')
ModelIter = override(ModelIter)
__all__.append('ModelIter')


Esempio n. 9
0
            itr = self.get_iter_at_row(itr)
        return RowWrapper(self, itr)
    
    def __setitem__ (self, itr, row):
        max_col = self.get_n_columns ()
        for column, value in enumerate (row):
            if column >= max_col:
                raise IndexError, "Too many columns in row assignment: %s" % column
            self.set_value (itr, column, value)
    
    def get_row (self, itr):
        return self[itr]
    
    def __iter__ (self):
        itr = self.get_first_iter ()
        last = self.get_last_iter ()
        while itr != last:
            yield self.get_row(itr)
            itr = self.next(itr)
        raise StopIteration
    
    def __len__ (self):
        return self.get_n_rows()
        
        

Model = override(Model)
__all__.append('Model')


Esempio n. 10
0
from gi.overrides import override
from gi.importer import modules
"""
The only purpose of this file is to ensure the XApp widget GType is registered
at the time of import.  Otherwise any user of XApp.GtkWindow would have to create
a dummy widget prior to using a GtkBuilder to parse a ui file containing an
XAppGtkWindow.

The gi import machinery sweeps usr/lib/python*/dist-packages/gi/overrides for file
matching the module name at the time of execution.

This file needs to be in both python2 and python3 overrides locations.

"""

XApp = modules['XApp']._introspection_module

__all__ = []


class GtkWindow(XApp.GtkWindow):
    pass


GtkWindow = override(GtkWindow)
__all__.append('GtkWindow')
Esempio n. 11
0
            self.set_property("size", size)

        if mountpoint:
            self.set_property("mountpoint", mountpoint)

    @property
    def size(self):
        # using get_property causes problems with pylint for some reason
        # pylint: disable-msg=E1101
        return self.get_property("size")

    @size.setter
    def size(self, size):
        self.set_property("size", size)

MountpointSelector = override(MountpointSelector)
__all__.append('MountpointSelector')

class SpokeSelector(Anaconda.SpokeSelector):
    def __init__(self, title=None, icon=None, status=None):
        Anaconda.SpokeSelector.__init__(self)

        if title:
            self.set_property("title", title)

        if icon:
            self.set_property("icon", icon)

        if status:
            self.set_property("status", status)
Esempio n. 12
0
            raise AttributeError

        if isinstance(other, six.integer_types):
            return ByteSize.Size.div_int(self, other)
        else:
            return Decimal(ByteSize.Size.true_div(self, other))

    def __truediv__(self, other):
        if isinstance(other, six.integer_types):
            return Decimal(ByteSize.Size.true_div_int(self, other))

        return Decimal(ByteSize.Size.true_div(self, other))

    def __floordiv__(self, other):
        if isinstance(other, six.integer_types):
            return ByteSize.Size.div_int(self, other)

        return ByteSize.Size.div(self, other)

    def __mod__(self, other):
        return ByteSize.Size.mod(self, other)

    def __repr__(self):
        return "Size (%s)" % self.human_readable(ByteSize.Bunit.B, -1, False)

    def __str__(self):
        return self.human_readable()

Size = override(Size)
__all__.append("Size")
Esempio n. 13
0
            return self.get_object()
        elif gtype == TYPE_UNICHAR:
            return self.get_uint()
        elif gtype == TYPE_GTYPE:
            return self.get_gtype()
        elif gtype == TYPE_VARIANT:
            return self.get_variant()
        elif gtype == TYPE_PYOBJECT:
            pass
        else:
            return None

    def __repr__(self):
        return '<Value (%s) %s>' % (self.g_type.name, self.get_value())

Value = override(Value)
__all__.append('Value')


def type_from_name(name):
    type_ = GObjectModule.type_from_name(name)
    if type_ == TYPE_INVALID:
        raise RuntimeError('unknown type name: %s' % name)
    return type_

__all__.append('type_from_name')


def type_parent(type_):
    parent = GObjectModule.type_parent(type_)
    if parent == TYPE_INVALID:
Esempio n. 14
0
import sys
from gi.repository import GObject
from gi.overrides import override
from gi.module import get_introspection_module

Gwy = get_introspection_module('Gwy')

__all__ = []

def match_signature(args, types):
    if len(args) != len(types):
        return False

    for pair in zip(args, types):
        if not issubclass(pair[0], pair[1]):
            return False
    return True

class Unit(Gwy.Unit):
    def __nonzero__(self):
        return not self.is_empty()

Unit = override(Unit)
__all__.append('Unit')
Esempio n. 15
0
    @staticmethod
    def create(*args, **kwargs):
        if len(kwargs) > 0:
            result = kwargs_to_result_variant(**kwargs)
            return Unity.ScopeResult.create_from_variant(result)
        return Unity.ScopeResult.create(*args)


class SearchContext(Unity.SearchContext):

    @staticmethod
    def create(search_query, search_type, filter_state, metadata_dict, result_set, cancellable):
        context = Unity.SearchContext.create(search_query, search_type, filter_state, None, result_set, cancellable)
        if metadata_dict and len(metadata_dict) > 0:
            metadata_variant = dict_to_variant(metadata_dict)
            context.set_search_metadata(Unity.SearchMetadata.create_from_variant(metadata_variant))

        return context


ScopeSearchBase = override(ScopeSearchBase)
__all__.append('ScopeSearchBase')
ResultPreviewer = override(ResultPreviewer)
__all__.append('ResultPreviewer')
ResultSet = override(ResultSet)
__all__.append('ResultSet')
ScopeResult = override(ScopeResult)
__all__.append('ScopeResult')
SearchContext = override(SearchContext)
__all__.append('SearchContext')
Esempio n. 16
0
               "mpath": BlockDev.Plugin.MPATH,
               "kbd": BlockDev.Plugin.KBD,
               "part": BlockDev.Plugin.PART,
               "fs": BlockDev.Plugin.FS,
               "s390": BlockDev.Plugin.S390,
               "nvdimm": BlockDev.Plugin.NVDIMM,
               "vdo": BlockDev.Plugin.VDO,
}


class ExtraArg(BlockDev.ExtraArg):
    def __new__(cls, opt, val=""):
        ret = BlockDev.ExtraArg.new(opt, val)
        ret.__class__ = cls
        return ret
ExtraArg = override(ExtraArg)
__all__.append("ExtraArg")

def _get_extra(extra, kwargs, cmd_extra=True):
    # pylint: disable=no-member
    # pylint doesn't really get how ExtraArg with overrides work
    if extra:
        if isinstance(extra, dict):
            ea = [ExtraArg.new(key, val) for key, val in extra.items()]
        elif isinstance(extra, list) and all(isinstance(arg, BlockDev.ExtraArg) for arg in extra):
            ea = extra
        else:
            msg = "extra arguments can only be given as a list of ExtraArg items or a as a dict"
            raise ValueError(msg)
    else:
        ea = []
Esempio n. 17
0
    "mpath": BlockDev.Plugin.MPATH,
    "kbd": BlockDev.Plugin.KBD,
    "part": BlockDev.Plugin.PART,
    "fs": BlockDev.Plugin.FS,
    "s390": BlockDev.Plugin.S390,
}


class ExtraArg(BlockDev.ExtraArg):
    def __new__(cls, opt, val=""):
        ret = BlockDev.ExtraArg.new(opt, val)
        ret.__class__ = cls
        return ret


ExtraArg = override(ExtraArg)
__all__.append("ExtraArg")


def _get_extra(extra, kwargs):
    # pylint: disable=no-member
    # pylint doesn't really get how ExtraArg with overrides work
    if extra:
        if isinstance(extra, dict):
            ea = [ExtraArg.new(key, val) for key, val in extra.items()]
        elif isinstance(extra, list) and all(
                isinstance(arg, BlockDev.ExtraArg) for arg in extra):
            ea = extra
        else:
            msg = "extra arguments can only be given as a list of ExtraArg items or a as a dict"
            raise ValueError(msg)
Esempio n. 18
0
            self.set_property("size", size)

        if mountpoint:
            self.set_property("mountpoint", mountpoint)

    @property
    def size(self):
        # using get_property causes problems with pylint for some reason
        # pylint: disable-msg=E1101
        return self.get_property("size")

    @size.setter
    def size(self, size):
        self.set_property("size", size)

MountpointSelector = override(MountpointSelector)
__all__.append('MountpointSelector')

class SpokeSelector(Anaconda.SpokeSelector):
    def __init__(self, title=None, icon=None, status=None):
        Anaconda.SpokeSelector.__init__(self)

        if title:
            self.set_property("title", title)

        if icon:
            self.set_property("icon", icon)

        if status:
            self.set_property("status", status)
Esempio n. 19
0
    def get_row(self, itr):
        return self[itr]

    def __iter__(self):
        itr = self.get_first_iter()
        last = self.get_last_iter()
        while itr != last:
            yield self.get_row(itr)
            itr = self.next(itr)
        raise StopIteration

    def __len__(self):
        return self.get_n_rows()


class ModelIter(Dee.ModelIter):
    def __init__(self):
        Dee.ModelIter.__init__(self)

    def __eq__(self, other):
        if not isinstance(other, ModelIter):
            return False
        return repr(self) == repr(other)


Model = override(Model)
__all__.append('Model')
ModelIter = override(ModelIter)
__all__.append('ModelIter')
Esempio n. 20
0
               "swap": BlockDev.Plugin.SWAP,
               "mdraid": BlockDev.Plugin.MDRAID,
               "mpath": BlockDev.Plugin.MPATH,
               "kbd": BlockDev.Plugin.KBD,
               "part": BlockDev.Plugin.PART,
               "fs": BlockDev.Plugin.FS,
               "s390": BlockDev.Plugin.S390,
}


class ExtraArg(BlockDev.ExtraArg):
    def __new__(cls, opt, val=""):
        ret = BlockDev.ExtraArg.new(opt, val)
        ret.__class__ = cls
        return ret
ExtraArg = override(ExtraArg)
__all__.append("ExtraArg")

def _get_extra(extra, kwargs):
    # pylint: disable=no-member
    # pylint doesn't really get how ExtraArg with overrides work
    if extra:
        if isinstance(extra, dict):
            ea = [ExtraArg.new(key, val) for key, val in extra.items()]
        elif isinstance(extra, list) and all(isinstance(arg, BlockDev.ExtraArg) for arg in extra):
            ea = extra
        else:
            msg = "extra arguments can only be given as a list of ExtraArg items or a as a dict"
            raise ValueError(msg)
    else:
        ea = []
Esempio n. 21
0
        elif gtype == TYPE_VARIANT:
            # get_variant was missing annotations
            # https://gitlab.gnome.org/GNOME/glib/merge_requests/492
            return self.dup_variant()
        elif gtype == TYPE_PYOBJECT:
            return self.get_boxed()
        elif gtype == _gi.TYPE_INVALID:
            return None
        else:
            return _gi._gvalue_get(self)

    def __repr__(self):
        return '<Value (%s) %s>' % (self.g_type.name, self.get_value())


Value = override(Value)
__all__.append('Value')


def type_from_name(name):
    type_ = GObjectModule.type_from_name(name)
    if type_ == TYPE_INVALID:
        raise RuntimeError('unknown type name: %s' % name)
    return type_


__all__.append('type_from_name')


def type_parent(type_):
    parent = GObjectModule.type_parent(type_)
        if mountpoint:
            self.set_property("mountpoint", mountpoint)

    @property
    def size(self):
        # using get_property causes problems with pylint for some reason
        # pylint: disable-msg=E1101
        return self.get_property("size")

    @size.setter
    def size(self, size):
        self.set_property("size", size)


MountpointSelector = override(MountpointSelector)
__all__.append('MountpointSelector')


class SpokeSelector(Anaconda.SpokeSelector):
    def __init__(self, title=None, icon=None, status=None):
        Anaconda.SpokeSelector.__init__(self)

        if title:
            self.set_property("title", title)

        if icon:
            self.set_property("icon", icon)

        if status:
            self.set_property("status", status)