This file is indexed.

/usr/share/doc/python-gtkmvc-doc/examples/converter/src/models/currencies.py is in python-gtkmvc-doc 1.99.1-1.

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
#  Author: Roberto Cavada <roboogle@gmail.com>
#
#  Copyright (c) 2006 by Roberto Cavada
#
#  pygtkmvc is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Lesser General Public
#  License as published by the Free Software Foundation; either
#  version 2 of the License, or (at your option) any later version.
#
#  pygtkmvc 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
#  Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public
#  License along with this library; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor,
#  Boston, MA 02110, USA.
#
#  For more information on pygtkmvc see <http://pygtkmvc.sourceforge.net>
#  or email to the author <roboogle@gmail.com>.
#  Please report bugs to <roboogle@gmail.com>.


import utils._importer
import utils.globals

from currency import CurrencyModel

from gtkmvc import ListStoreModel
import os.path
import gobject

import xml.parsers.expat


class CurrenciesModel (ListStoreModel):
    """Model the currencies set. If a model is loaded from file, the
    file is kept aligned if the model is changed later"""

    def __init__(self, filename=None):

        ListStoreModel.__init__(self, gobject.TYPE_PYOBJECT # currency model
                                );
        self.parser = xml.parsers.expat.ParserCreate()
        self.parser.StartElementHandler = self.__start_element
        self.parser.EndElementHandler = self.__end_element
        self.parser.CharacterDataHandler = self.__char_data

        self.__init_parser()
        
        self.load(filename)        
        return

    def add(self, model):
        """raises an exception if the model cannot be added"""
        def foo(m, p, i):
            if m[i][0].name == model.name:
                raise ValueError("Model already exists")
            return
        # checks if already existing
        self.foreach(foo)
        
        self.append((model,))
        return


    def load(self, filename):
        self.filename = filename
        if filename is None: return

        f = open(self.filename, "r")
        self.parser.ParseFile(f)
        return



    # ----------------------------
    #   Private methods
    # ----------------------------
    def __init_parser(self):
        self.__elem_stack = []
        self.__curr_data = ""
        self.__elems = {
            "name" : None,
            "rate" : None,
            "notes" : None,
            }
            
        return


    def __start_element(self, name, attrs):
        self.__elem_stack.append(name)
        self.__curr_data = ""
        return

    def __end_element(self, name):
        top = self.__elem_stack.pop()
        assert(top == name)

        if name in self.__elems:
            self.__elems[name] = self.__curr_data.strip()
            self.__curr_data = ""
            
        elif name == "currency":
            m = CurrencyModel(self.__elems["name"],
                              float(self.__elems["rate"]),
                              self.__elems["notes"])
            self.add(m)

        else: assert(name == "currencies")
        
        return

    def __char_data(self, data):
        self.__curr_data += data
        return

    pass # end of class