This file is indexed.

/usr/share/pyshared/pyxine/config.py is in python-pyxine 0.1alpha2-8.

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
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# $Id: config.py,v 1.1.1.1 2003/02/08 00:42:20 dairiki Exp $
#
# Copyright (C) 2003  Geoffrey T. Dairiki <dairiki@dairiki.org>
#
# This file is part of Pyxine, Python bindings for xine.
#
# Pyxine 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.
#
# Pyxine 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.

from pyxine import libxine, cstruct, constants, constwrap
import inspect

class _ConfigEntry(object):
    def __init__(self, rep):
        self.rep = rep

    key = property(lambda s: s.rep.key)
    type = property(lambda s: constwrap.XINE_CONFIG_TYPE(s.rep.type))
    description = property(lambda s: s.rep.description)
    help = property(lambda s: s.rep.help)
    exp_level = property(lambda s: s.rep.exp_level)

    def __repr__(self):
        def is_property(p): return type(p) == property
        d = {}
        for k,v in inspect.getmembers(self.__class__, is_property):
            d[k] = getattr(self, k)
        return "<%s: %s>" % (self.__class__.__name__, d)

    __str__ = __repr__
    
class _Num_ConfigEntry(_ConfigEntry):
    def _set_value(self, val):
        self.rep.num_value = val
    value = property(lambda s: s.rep.num_value, _set_value)
    default = property(lambda s: s.rep.num_default)

    def __str__(self):
        return str(self.value)
    def __int__(self):
        return self.value
    
class _Bool_ConfigEntry(_Num_ConfigEntry):
    pass

class _Range_ConfigEntry(_Num_ConfigEntry):
    min = property(lambda s: s.rep.range_min)
    max = property(lambda s: s.rep.range_max)

class _String_ConfigEntry(_ConfigEntry):
    def _set_value(self, val):
        self.rep.str_value = val
    value = property(lambda s: s.rep.str_value, _set_value)
    default = property(lambda s: s.rep.str_default)
    sticky = property(lambda s: s.rep.str_sticky) # FIXME: what is this ??

    def __str__(self):
        return self.value

class _Enum_ConfigEntry(_ConfigEntry):
    values = property(lambda s: s.rep.enum_values)
    enum_values = values

    def _set_num_value(self, val):
        try:
            self.values[val]
        except IndexError:
            raise ValueError
        self.rep.num_value = val
    num_value = property(lambda s: s.rep.num_value, _set_num_value)
    num_default = property(lambda s: s.rep.num_default)
    
    def _set_value(self, val):
        if type(val) is int:
            self.rep.num_value = val
        else:
            self.rep.num_value = list(self.values).index(val)
    value = property(lambda s: s.values[s.rep.num_value], _set_value)
    default = property(lambda s: s.values[s.rep.num_default])

    def __str__(self):
        return self.value

_config_entry_types = {
    constants.XINE_CONFIG_TYPE_RANGE: _Range_ConfigEntry,
    constants.XINE_CONFIG_TYPE_STRING: _String_ConfigEntry,
    constants.XINE_CONFIG_TYPE_ENUM: _Enum_ConfigEntry,
    constants.XINE_CONFIG_TYPE_NUM: _Num_ConfigEntry,
    constants.XINE_CONFIG_TYPE_BOOL: _Bool_ConfigEntry,
    }

def xine_cfg_entry_t(packed):
    rep = cstruct.xine_cfg_entry_t(packed)
    proxy = _config_entry_types.get(rep.type, _ConfigEntry)
    return proxy(rep)


def _wrap_cb(cb):
    if cb is None:
        return None
    def wrapper(entry):
        cb(xine_cfg_entry_t(entry))
    return wrapper

class XineConfig:
    def __init__(self, xine):
        self.this = xine.this
        self.xine = xine

    def load(self, cfg_filename):
        if self.xine.cfg_filename is not None:
            self.reset()
        libxine.xine_config_load(self.this, cfg_filename)
        self.xine.cfg_filename = cfg_filename

    def save(self, cfg_filename=None):
        cfg_filename = cfg_filename or self.xine.cfg_filename
        libxine.xine_config_save(self.this, cfg_filename)
        self.xine.cfg_filename = cfg_filename

    def reset(self):
        libxine.xine_config_reset(self.this)
        self.xine.cfg_filename = None
        
    def values(self):
        v = []
        try:
            entry = libxine.xine_config_get_first_entry(self.this)
            while 1:
                v.append(xine_cfg_entry_t(entry))
                entry = libxine.xine_config_get_next_entry(self.this)
        except StopIteration:
            pass
        return v
    def keys(self):
        return map(lambda entry: entry.key, self.values())
    def items(self):
        return map(lambda entry: (entry.key, entry), self.values())
    def itervalues(self):
        return iter(self.values())
    def iterkeys(self):
        return iter(self.keys())
    def iteritems(self):
        return iter(self.items())
    def __iter__(self):
        return self.iterkeys()
    
    def __getitem__(self, key):
        entry = libxine.xine_config_lookup_entry(self.this, key)
        return xine_cfg_entry_t(entry)

    def __setitem__(self, key, value):
        entry = self[key]
        entry.value = value
        libxine.xine_config_update_entry(self.this, entry.rep.this)

            
    def register_string(self, key, def_value="",
                        description="", help="", exp_level=0,
                        changed_cb=None):
        return libxine.xine_config_register_string(
            self.this, key, def_value,
            description, help, exp_level,
            _wrap_cb(changed_cb))

    def register_range(self, key, def_value=0, min=0, max=100,
                       description="", help="", exp_level=0,
                       changed_cb=None):
        return libxine.xine_config_register_range(
            self.this, key, def_value, min, max,
            description, help, exp_level,
            _wrap_cb(changed_cb))

    def register_enum(self, key, def_value=0, values=(),
                      description="", help="", exp_level=0,
                      changed_cb=None):

        num_val = libxine.xine_config_register_enum(
            self.this, key, def_value, values,
            description, help, exp_level,
            _wrap_cb(changed_cb))
        return values[num_val]

    def register_num(self, key, def_value=0,
                     description="", help="", exp_level=0,
                     changed_cb=None):
        return libxine.xine_config_register_num(
            self.this, key, def_value,
            description, help, exp_level,
            _wrap_cb(changed_cb))

    def register_bool(self, key, def_value=0,
                      description="", help="", exp_level=0,
                      changed_cb=None):
        return libxine.xine_config_register_bool(
            self.this, key, def_value,
            description, help, exp_level,
            _wrap_cb(changed_cb))