Code Duplication    Length = 17-18 lines in 2 locations

tube/tubeAPI.py 2 locations

@@ 221-238 (lines=18) @@
218
			ret.update(Tube().map.get(linecode=l, stationcode=self.code).getAllTrains() )
219
		return ret
220
221
222
class TubeStationManager(dict):
223
	def __init__(self):
224
		pass
225
	def addStation(self, station):
226
		if not self.has_key(station.code):
227
			self[station.code] = station
228
229
class TubeLine(object):
230
	def __init__(self, code, name):
231
		self.code 		= code
232
		self.name 		= name
233
		self._stations 	= TubeStationManager()
234
235
	def __repr__(self):
236
		return "<Tube.Line: %s>" % self.name
237
238
	def getStations(self):
239
		return self._stations
240
241
	def getAllTrains(self):
@@ 195-211 (lines=17) @@
192
			newP.track_code = p.platform_number
193
			newP.next_train = p.track_code
194
			self.platforms[newP.name] = newP
195
196
	def getAllTrains(self):
197
		ret = {}
198
		for plat in self.platforms.keys():
199
			ret.update(self.platforms[plat].trains)
200
		return ret
201
202
203
class TubeStation(object):
204
	def __init__(self, code, name):
205
		self.code 		= code
206
		self.name 		= name
207
		self._lines 	= TubeLineManager()
208
209
	def __repr__(self):
210
		return "<Tube.Station: %s>" % self.name
211
212
	def getLines(self):
213
		return self._lines
214