This file is indexed.

/usr/share/pyshared/hotwire_ui/pixbufcache.py is in hotwire 0.721-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# This file is part of the Hotwire Shell user interface.
#   
# Copyright (C) 2007 Colin Walters <walters@verbum.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

import os,sys,logging

import gtk, gobject

from hotwire.externals.singletonmixin import Singleton
from hotwire.async import MiniThreadPool

def _get_datadirs():
    datadir_env = os.getenv('XDG_DATA_DIRS')
    if datadir_env:
        datadirs = datadir_env.split(':')
    else:
        datadirs = ['/usr/share/']
    for d in datadirs:
        yield os.path.join(d, 'hotwire', 'images')
    uninst = os.getenv('HOTWIRE_UNINSTALLED') 
    if uninst:
        yield os.path.join(uninst, 'images')

def _find_in_datadir(fname):
    datadirs = _get_datadirs()
    for dir in datadirs:
        fpath = os.path.join(dir, fname)
        if os.access(fpath, os.R_OK):
            return fpath
    return None

class PixbufCache(Singleton):
    def __init__(self):
        super(PixbufCache, self).__init__()
        self.__cache = {}

    def get(self, path, size=24, animation=False, trystock=False, stocksize=None):
        if trystock:
            pixbuf = self.get_stock(path, size)
            if pixbuf:
                return pixbuf
        if not os.path.isabs(path):
            path = _find_in_datadir(path)
        if not path:
            return None        
        if not self.__cache.has_key((path, size)):
            pixbuf = self.__do_load(path, size, animation)
            self.__cache[(path, size)] = pixbuf
        return self.__cache[(path, size)]
    
    def get_stock(self, name, size=24):
        if name.find(os.sep) >= 0:
            name = os.path.basename(name)
        (root, ext) = os.path.splitext(name)
        theme = gtk.icon_theme_get_default()
        try:
            return theme.load_icon(name, size, 0)
        except gobject.GError, e:
            return None
        
    def __do_load(self, path, size, animation):
        f = open(path, 'rb')
        data = f.read()
        f.close()
        loader = gtk.gdk.PixbufLoader()
        if size:
            loader.set_size(size, size)
        loader.write(data)
        loader.close()
        if animation:
            return loader.get_animation()
        return loader.get_pixbuf()