Exemple #1
0
    def get(self, line):
        result = []
        line = line.upper()
        l = Line.get_by_name(line)

        if l is None:
            s = Line.search_by_name(line)
            result.append('Line not found')
            if s:
                result.append('Did you mean:')
                for line in s:
                    result.append(line['name'])
        else:
            i = 1
            for direction in l.get_stations():
                result.append('* Direction %d' % i)
                result += [station['name'] for station in direction]
                if i == 1:
                    result.append('')
                i += 1

        return result
Exemple #2
0
    def get(self, line):
        result = []
        line = line.upper()
        l = Line.get_by_name(line)

        if l is None:
            s = Line.search_by_name(line)
            result.append('Line not found')
            if s:
                result.append('Did you mean:')
                for line in s:
                    result.append(line['name'])
        else:
            i = 1
            for direction in l.get_stations():
                result.append('* Direction %d' % i)
                result += [station['name'] for station in direction]
                if i == 1:
                    result.append('')
                i += 1

        return result
Exemple #3
0
group.add_argument('-d', '--departures', action='store_true',
                   help='show departures', dest='deps')
group.add_argument('-l', '--line', action='store_true',
                   help='show stations', dest='line')

args = parser.parse_args()

stations = Station.search_by_name(args.name, weight='line_count')

if args.search:
    for station in map(lambda x: x['name'], stations):
        print(station)

if args.line:
    name = args.name.upper()
    l = Line.get_by_name(name)

    if l is None:
        s = Line.search_by_name(name)
        print('Line not found')
        if s:
            print('Did you mean:')
            for line in s:
                print(line['name'])
        sys.exit(1)
    else:
        i = 1
        for direction in l.get_stations():
            print()
            print('-'*12)
            print(inred('Direction:'), i)