def match_stations_with_lines(from_station, to_station, lines=None): def match(a, b, L): """检查L中包含a和b且a比b靠前""" try: return L.index(a) < L.index(b) except ValueError: return False if not lines: lines = BeijingBus.get_all_lines() return [line for line in lines if match(from_station, to_station, line.stations)]
def list_supported_lines(): names = set([ line.short_name for line in BeijingBus.get_all_lines() ]) return '''<!DOCTYPE html> <html lang="zh-CN"> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>支持的线路的列表</title> </head> <body>%s</body> </html> ''' % ''.join(['<p>%s</p>' % name for name in sorted(names)])
def match_stations_with_lines(from_station, to_station, lines=None): def match(a, b, l): '''检查l中包含a和b且a比b靠前''' try: return l.index(a) < l.index(b) except ValueError: return False if not lines: lines = BeijingBus.get_all_lines() return [ line for line in lines if match(from_station, to_station, line.stations) ]
def list_supported_lines(): names = set([line.short_name for line in BeijingBus.get_all_lines()]) names = sorted([n.decode("utf-8") for n in names]) return render_template("list.html", line_names=names)
def list_supported_lines(): names = set([ line.short_name for line in BeijingBus.get_all_lines() ]) names = sorted([n.decode('utf-8') for n in names]) return render_template('list.html', line_names=names)