Beispiel #1
0
 def __init__(self, _filename_or_resource, _file_marker='@',
              _file_prefix=None, _check_booleans=False,
              _use_as_resources=False):
     if is_resource(_filename_or_resource):
         self.__properties = cfg.ConfigObj(_filename_or_resource.handler)
         _filename_or_resource.close()
     else:
         self.__properties = cfg.ConfigObj(_filename_or_resource)
     self.__file_marker = _file_marker
     self.__file_prefix = _file_prefix
     self.__check_booleans = _check_booleans
     self.__use_as_resources = _use_as_resources
Beispiel #2
0
def get_resource_as_icon(iconfilename_or_resource):
    """
    if parameter is simple string then it is used as parameter for QIcon
    object, if parameter is of resource type then a conversion from a resource
    object (usually represented by string of bytes) to QIcon object
    is taken place, the conversion is possible if resource represents some
    real image object
    """
    if is_resource(iconfilename_or_resource):
        pixmap = QPixmap()
        pixmap.loadFromData(QByteArray(iconfilename_or_resource.data))
        return QIcon(pixmap)
    else:
        return QIcon(iconfilename_or_resource)
Beispiel #3
0
 def __init__(self,
              _filename_or_resource,
              _file_marker='@',
              _file_prefix=None,
              _check_booleans=False,
              _use_as_resources=False):
     if is_resource(_filename_or_resource):
         self.__properties = cfg.ConfigObj(_filename_or_resource.handler)
         _filename_or_resource.close()
     else:
         self.__properties = cfg.ConfigObj(_filename_or_resource)
     self.__file_marker = _file_marker
     self.__file_prefix = _file_prefix
     self.__check_booleans = _check_booleans
     self.__use_as_resources = _use_as_resources
Beispiel #4
0
    def get(self, **params):
        attr = get_keys_for_value(params, GLOBALS.ITEM, _one_key_only=True)
        if not hasattr(self, attr):
            return None

        value = getattr(self, get_keys_for_value(params, GLOBALS.ITEM,
                                                 _one_key_only=True))
        if len(params) > 1:
            param_keys = get_for_regexpr(params.keys(), '^PARAM[0-9]*$')
            if param_keys:
                for key in param_keys:
                    if is_resource(value):
                        value.resource = \
                            value.resource.replace("{" + key[5:] + "}",
                                                   params[key])
                    else:
                        value = value.replace("{" + key[5:] + "}", params[key])

        return value
Beispiel #5
0
    def get(self, **params):
        attr = get_keys_for_value(params, GLOBALS.ITEM, _one_key_only=True)
        if not hasattr(self, attr):
            return None

        value = getattr(
            self, get_keys_for_value(params, GLOBALS.ITEM, _one_key_only=True))
        if len(params) > 1:
            param_keys = get_for_regexpr(params.keys(), '^PARAM[0-9]*$')
            if param_keys:
                for key in param_keys:
                    if is_resource(value):
                        value.resource = \
                            value.resource.replace("{" + key[5:] + "}",
                                                   params[key])
                    else:
                        value = value.replace("{" + key[5:] + "}", params[key])

        return value