コード例 #1
0
 def get_po_catalog(self):
     cat = StringIO()
     with closing(zipopen(self.file_base + '.po')) as f:
         po = read_po(f)
         write_mo(cat, po)
         cat.seek(0)
         return cat
コード例 #2
0
ファイル: plugin_registry.py プロジェクト: AlexUlrich/digsby
 def get_po_catalog(self):
     cat = StringIO()
     with closing(zipopen(self.file_base + '.po')) as f:
         po = read_po(f)
         write_mo(cat, po)
         cat.seek(0)
         return cat
コード例 #3
0
def getcontent(str_or_path):
    try:
        if str_or_path.isfile():
            return str_or_path.bytes(), str_or_path
        with closing(zipopen(str_or_path)) as f:
            return f.read(), str_or_path
    except AttributeError:
        return str_or_path, '<String Input>'
コード例 #4
0
def skinfile(name, paths, exc = True):
    #fast loop
    for p in reversed(paths):
        imgpath = p / name
        if imgpath.isfile():
            return imgpath
    #slow loop
    for p in reversed(paths):
        imgpath = p / name
        try:
            foo = zipopen(imgpath).read()
        except Exception:
            pass
        else:
            if foo is not None:
                return imgpath

    if exc:
        raise SkinException('could not find skinfile %s (paths: %r)' % (name, paths))
    else:
        return None
コード例 #5
0
def _loadimage(path, return_bitmap = False):
    try:
        if path.isfile():
            img = Image(path, BITMAP_TYPE_ANY)
        else:
            f = None
            try:
                f = zipopen(path)
                if f is None:
                    raise IOError('Image ' + path + ' does not exist')
                img = ImageFromString(f.read())
            finally:
                if f is not None:
                    f.close()

        if not img.HasAlpha():
            img.InitAlpha()

        val = img if not return_bitmap else BitmapFromImage(img)
        val.path = path
        return val

    except Exception, err:
        raise AssertionError(err)
コード例 #6
0
 def get_mo_catalog(self):
     with closing(zipopen(self.file_base + '.mo')) as f:
         return StringIO(f.read())
コード例 #7
0
ファイル: plugin_registry.py プロジェクト: AlexUlrich/digsby
 def get_mo_catalog(self):
     with closing(zipopen(self.file_base + '.mo')) as f:
         return StringIO(f.read())