def rescan(self):
        """Rescan the directory and check for changed functions"""
        names = []
        for res in resource_search("*.function"):
            try:
                func = Function()
                func.fromstring(resource_data(res))
                func.filename = res
                names.append(func.name)
            except IOError:
                continue

            if func.name not in [f.name for f in self.functions]:
                self.functions.append(func)
                self.emit('added', func)
            else:
                for i, f in enumerate(self.functions):
                    if f.name == func.name:
                        self.functions[i] = func
                        self.emit('modified', func)

        for f in self:
            if f.name not in names:
                self.functions.remove(f)
                self.emit('removed', f)
Example #2
0
def getimage(name, cache={}):
    if name not in cache:
        resource = images[name]
        pix = QPixmap()
        pix.loadFromData(resource_data(resource))
        cache[name] =  pix
    return cache[name]