Esempio n. 1
0
def handler(frequency=None, channel=None):

    qrgfiles = glob.glob(get_data_file('*.qrg'))
    result = []

    if channel:
        search = channel.replace('-', '')
    elif frequency:
        search = Decimal(frequency.replace(',', '.'))
        search = '%d' % (search * 1000000)
    else:
        return

    for file in qrgfiles:
        signreader = csv.reader(open(file), delimiter=',')

        for row in signreader:
            if len(row) != 3:
                continue

            freq, mode, name = map(decode, row)

            if re.match(search, freq) or re.match(search, name.replace('-', '')):
                result.append('%.3f - %s (%s)' % (Decimal(freq) / 1000000, name, mode))

    if not result:
        return ['%s er ukjent' % (frequency or channel)]

    return result
Esempio n. 2
0
def handler(frequency=None, channel=None):

    qrgfiles = glob.glob(get_data_file('*.qrg'))
    result = []

    if channel:
        search = channel.replace('-', '')
    elif frequency:
        search = Decimal(frequency.replace(',', '.'))
        search = '%d' % (search * 1000000)
    else:
        return

    for file in qrgfiles:
        signreader = csv.reader(open(file), delimiter=',')

        for row in signreader:
            if len(row) != 3:
                continue

            freq, mode, name = map(decode, row)

            if re.match(search, freq) or re.match(search, name.replace(
                    '-', '')):
                result.append('%.3f - %s (%s)' %
                              (Decimal(freq) / 1000000, name, mode))

    if not result:
        return ['%s er ukjent' % (frequency or channel)]

    return result
Esempio n. 3
0
def handler(callsign=None):

    signfile = get_data_file('callsigns.csv')
    signreader = csv.reader(open(signfile), delimiter=';')

    result = []

    for row in signreader:
        call, name, addr, code, place = map(decode, row[:5])

        if call == callsign:
            result.append('%-7s %s (%s)' % (call, name, place))
        elif re.search(callsign, name, re.I):
            result.append('%-7s %s (%s)' % (call, name, place))

    if not result:
        return ['%s er ukjent' % callsign]
    elif len(result) > 5:
        return result[:5] + ['og %d til...' % (len(result) - 5)]

    return result
Esempio n. 4
0
def handler(callsign=None):

    signfile = get_data_file('callsigns.csv')
    signreader = csv.reader(open(signfile), delimiter=';')

    result = []

    for row in signreader:
        call, name, addr, code, place = map(decode, row[:5])

        if call == callsign:
            result.append('%-7s %s (%s)' % (call, name, place))
        elif re.search(callsign, name, re.I):
            result.append('%-7s %s (%s)' % (call, name, place))

    if not result:
        return ['%s er ukjent' % callsign]
    elif len(result) > 5:
        return result[:5] + ['og %d til...' % (len(result) - 5)]

    return result