This file is indexed.

/usr/share/pyshared/glpk/model_objects.py is in python-glpk 0.4.52-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
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
"""
   Filename:  model_objects.py (tools for processing GnuMathProg language)

-- This code is part of the Python-GLPK interface.
--
-- Copyright (C) 2005, Joao Pedro Pedroso and Filipe Brandao
-- Faculdade de Ciencias, Universidade do Porto
-- Porto, Portugal. All rights reserved. E-mail: <jpp@fc.up.pt>.
--
-- Python-GLPK 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, or (at your option) any
-- later version.
--  
-- Python-GLPK 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 GLPK; see the file COPYING. If not, write to the Free
-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-- 02110-1301, USA.
"""

def name_to_index(name):
    if type(name)==tuple:
        s = ''
        for i in range(len(name)):
            if i>0: s += ','
            if type(name[i])==str:
                if ',' not in name[i]:
                    t = name[i]
                else:
                    t = "'%s'" % (name[i])
            else:
                t = str(name[i])
            s += t
        return s
    else:
        return name

def join_bounds(cur, new):
    if cur == None:
        return new
    if new == None:
        return cur
    if new[0] == '=':
        return new
    else:
        cur = list(cur)
        if cur[0] == '=':
            cur = (None, None)
        if new[0] != None:
            cur[0] = new[0]
        if new[1] != None:
            cur[1] = new[1]
        return tuple(cur)
        
class var:
    def __init__(self, prob, name, value = None, bnds = None):
        self._prob = prob
        self._name = name
        self._subvars = None
        if type(value) != dict:
            self._value = value
        else:
            self._subvars = value

    def value(self):
        return self._value                     

    def _bounds(self):
        try:
            bnds = self._prob._bounds[self._name]
        except:
            bnds = None
        return bnds

    def _clear(self):
        self._prob._rm_bounds(self._name)                  
        
    def __del__(self):
        self.clear()
                
    def _set_bounds(self, bounds):
        self._prob._set_bounds(self._name, bounds)
        if self._subvars:
          for x in self:
            self[x]._set_bounds(bounds)
        
    def __eq__(self, value):
        self._set_bounds(('=', value))
        for x in self:
            self[x] == value
        return nothing()
        
    def __ge__(self, value):
        self._set_bounds(('>=', value))
        return nothing()
        
    def __le__(self, value):
        self._set_bounds(('<=', value))
        return nothing()
               
    def __str__(self):
        if self._subvars == None:
            return '(var:'+str(self._value)+')'
        else:
            return '(var:'+str(self._subvars)+')'

    def __repr__(self):
        return str(self)      
            
    def __getitem__(self, name):
        if self._subvars == None: return
        name = name_to_index(name)
        itemname = "%s[%s]" % (self._name, name)
        if name not in self._subvars:
            _var = var(self._prob, itemname) 
            self._subvars[name] = _var
        else:
            _var = self._subvars[name]
        return _var
        
    def __setitem__(self, name, value):
        if self._subvars == None: return
        name = name_to_index(name)
        itemname = "%s[%s]" % (self._name, name)
        new_var = var(self._prob, itemname) 
        self._subvars[name] = new_var
        new_var == value
        
    def __iter__(self):
        if self._subvars == None: return
        for x in self._subvars:
            yield x

class constraint(var):
    def __str__(self):
        if self._subvars == None:
            return '(constraint:'+str(self._value)+')'
        else:
            return '(constraint:'+str(self._subvars)+')'

class objective(var):
    def __str__(self):
        if self._subvars == None:
            return '(objective:'+str(self._value)+')'
        else:
            return '(objective:'+str(self._subvars)+')'
            
class nothing:
    def __repr__(self):
        return ''