Exemplo n.º 1
0
def arc2fdsnws(filein, fileout, config='../routing.cfg'):
    """Read the routing file in XML format and add the Dataselect and Station
routes based on the Arclink information. The resulting table is stored in the
file passed in the second parameter.

:param filein: Input file with routes (usually from an Arclink server).
:type filein: str
:param fileout: Output file with all routes from the input file plus new
                Station and Dataselect routes based on the Arclink route.
:type fileout: str
"""
    rc = RoutingCache(filein, config=config)
    rOut = RoutingCache()
    for st, lr in rc.routingTable.iteritems():
        toAdd = list()
        for r in lr:
            if r.service == 'arclink':
                stat = Route('station', '%s/fdsnws/station/1/query' %
                             mapArcFDSN(r.address), r.tw, r.priority)
                toAdd.append(stat)

                data = Route('dataselect', '%s/fdsnws/dataselect/1/query' %
                             mapArcFDSN(r.address), r.tw, r.priority)
                toAdd.append(data)

        try:
            rOut.routingTable[st].extend(toAdd)
        except:
            rOut.routingTable[st] = toAdd

    rOut.toXML(fileout)