Пример #1
0
	def getline(self):
		if self.via is None:
			result = [self.origin.getline(False)]+[self.destination.getline(False)]
		else:
			result = [tools.bold(self.origin.getline(True))]+[via.getline(True) for via in self.via]+[tools.bold(self.destination.getline(True))]
		result[0][-1] = '%s %s' % (str(self.mot), str(self.mot.destination) if not self.mot.walk else '%d min. (%dm)' % (self.duration, self.distance))
		return result
Пример #2
0
	def __str__(self):
		lines = []
		lines.append(  (tools.bold('Abfahrt:')+' %s – '+tools.bold('Ankunft:')+' %s – '+tools.bold('Dauer:')+' %s Minuten') % (self.parts[0].origin.get_formatted_time('departure'), self.parts[-1].destination.get_formatted_time('arrival'), self.duration)  )
		lines.append('-')
		lastpart = None
		for part in self.parts:
			if lastpart is not None:
				changetime = int((part.origin.get_maybelive_time('departure')-lastpart.destination.get_maybelive_time('arrival')).total_seconds())/60
				if changetime <= 0:
					if changetime == 0 and (lastpart.mot.walk or part.mot.walk):
						lines += ['']
					else:
						lines += ['%s%d Minuten Umsteigezeit%s' % (Style.BRIGHT+Fore.RED, changetime, Style.RESET_ALL)]
				elif changetime < 3:
					lines += ['%s%d Minuten Umsteigezeit%s' % (Style.BRIGHT+Fore.YELLOW, changetime, Style.RESET_ALL)]
				else:
					lines += ['%s%d Minuten Umsteigezeit%s' % (Style.DIM, changetime, Style.RESET_ALL)]
			lines += part.getline()
			lastpart = part
		lines.append('-')
		
		result = str(tools.Table(lines))
		result += '' if not len(self.infotext) else ('\n'.join(self.infotext)+'\n')
		return result
Пример #3
0
	def __str__(self):
		if self.unclear:
			result = ''
			if isinstance(self.origin, TripPointCompatibleUnclear): result += tools.bold('Unclear origin:\n')+str(self.origin)+'\n'
			if isinstance(self.destination, TripPointCompatibleUnclear): result += tools.bold('Unclear destination:\n')+str(self.destination)+'\n'
			if isinstance(self.via, TripPointCompatibleUnclear): result += tools.bold('Unclear via:\n')+str(self.via)+'\n'
		else:
			via = '' if isinstance(self.via, EmptyTripPoint) else (' via %s' % tools.bold(str(self.via)))
			result = 'Route von %s nach %s%s:\n' % (tools.bold(str(self.origin)), tools.bold(str(self.destination)), via)
			exclude = '' if not len(self.settings['exclude']) else ' – ohne '+', '.join([s.title() for s in self.settings['exclude']])
			result += '%s %s, %s%s\n\n' % (tools.bold({'arr':'Ankunft', 'dep':'Abfahrt'}[self.settings['timetype']]), self.time.strftime('%d.%m.%Y %H:%M'), {'local':'nur Nahverkehr', 'ic':'alles außer ICE', 'ice':'alle Zugtypen'}[self.settings['train_type']], exclude)
			
			result += '\n'.join([str(route) for route in self.routes])
		return result