/usr/share/pyshared/tp/netlib/discover/game.py is in python-tp-netlib 0.2.5-3.
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 | class Game(object):
def __init__(self, name):
self.name = name
self.locations = {}
self.required = {}
self.optional = {}
self.new = True
def __str__(self):
s = "<Game '%s' \n" % self.name
for type in self.locations.keys():
s+= "\t%s\t@ " % (type+'\t', type)[len(type) > 7]
for addr in self.locations[type]:
s+= "%s (%s) p %s, " % addr
s = s[:-2] + "\n"
s = s[:-1] + ">"
return s
__repr__ = __str__
def addLocation(self, type, addr):
if not self.locations.has_key(type):
self.locations[type] = []
if not addr in self.locations[type]:
self.locations[type].append(addr)
def removeLocation(self, type, addr=None):
"""\
Removes a location (type, addr) from this game.
Returns true is that was the last location.
"""
if self.locations.has_key(type):
if addr is None:
del self.locations[type]
elif addr in self.locations[type]:
self.locations[type].remove(addr)
if len(self.locations[type]) == 0:
del self.locations[type]
return len(self.locations) == 0
preference = ("tps", "tp", "tp+https", "tp+http")
def bestLocation(self):
for type in self.preference:
if self.locations.has_key(type):
return (type, self.locations[type][0])
return None
def updateOptional(self, optional):
self.optional.update(optional)
def updateRequired(self, required):
self.required.update(required)
def __getattr__(self, key):
if key in self.__dict__:
return self.__dict__[key]
if self.required.has_key(key):
return self.required[key]
if self.optional.has_key(key):
return self.optional[key]
raise AttributeError("No such attribute %s" % key)
|