def __iter__(self):
        events = []
        b = TreeBuilder()
        p = XMLParser(b)
        p._setevents(events, self._events)
        try:
            p.feed(self.content)
        except SyntaxError as e:
            self.err = e
            self.err_info = (p.CurrentLineNumber, p.CurrentColumnNumber,
                             p.CurrentByteIndex)

        for event in events:
            yield event
        del events[:]
        try:
            self.root = p.close()
        except SyntaxError as e:
            # if we had a previous syntax error, keep it
            if not self.err:
                self.err = e
                self.err_info = (p.CurrentLineNumber, p.CurrentColumnNumber,
                                 p.CurrentByteIndex)
        for event in events:
            yield event
Ejemplo n.º 2
0
    def __iter__(self):
        events = []
        b = TreeBuilder()
        p = XMLParser(b)
        p._setevents(events, self._events)
        try:
            p.feed(self.content)
        except SyntaxError as e:
            self.err = e
            self.err_info = (
                p.CurrentLineNumber, p.CurrentColumnNumber, p.CurrentByteIndex)

        for event in events:
            yield event
        del events[:]
        try:
            self.root = p.close()
        except SyntaxError as e:
            # if we had a previous syntax error, keep it
            if not self.err:
                self.err = e
                self.err_info = (
                    p.CurrentLineNumber, p.CurrentColumnNumber, p.CurrentByteIndex)
        for event in events:
            yield event
Ejemplo n.º 3
0
 def __iter__(self):
     events = []
     b = TreeBuilder()
     p = XMLParser(b)
     p._setevents(events, self._events)
     try:
         p.feed(self.content)
     except SyntaxError, e:
         self.err = e
         self.err_info = (p.CurrentLineNumber, p.CurrentColumnNumber, p.CurrentByteIndex)
Ejemplo n.º 4
0
 def __iter__(self):
     events = []
     b = TreeBuilder()
     p = XMLParser(b)
     p._setevents(events, self._events)
     try:
         p.feed(self.content)
     except SyntaxError, e:
         self.err = e
         self.err_info = (p.CurrentLineNumber, p.CurrentColumnNumber,
                          p.CurrentByteIndex)
Ejemplo n.º 5
0
def getPredictionsForStopId(stopId):
    predictionsUrl = getPredictionsUrlForStopId(stopId)
    request = urllib.urlopen(predictionsUrl)
    xmlResponse = request.read()
    print xmlResponse
    xmlParser = XMLParser()
    xmlParser.feed(xmlResponse)
    busResponseElement = xmlParser.close()
    routePredictionTimes = []
    try:
        for prd in busResponseElement.getchildren():
            route = prd.find('rt').text
            tmstmp = prd.find('prdtm').text
            heading = prd.find('des').text
            timeStamp = datetime.strptime(tmstmp, '%Y%m%d %H:%M')
            routePredictionTimes.append((route, timeStamp, heading))
    except:
        pass

    return routePredictionTimes
Ejemplo n.º 6
0
def getPredictionsForStopId(stopId):
    predictionsUrl = getPredictionsUrlForStopId(stopId)
    request = urllib.urlopen(predictionsUrl)
    xmlResponse = request.read()
    print xmlResponse
    xmlParser = XMLParser()
    xmlParser.feed(xmlResponse)
    busResponseElement = xmlParser.close()
    routePredictionTimes = []
    try:
        for prd in busResponseElement.getchildren():
            route = prd.find('rt').text
            tmstmp = prd.find('prdtm').text
            heading = prd.find('des').text
            timeStamp = datetime.strptime(tmstmp, '%Y%m%d %H:%M')
            routePredictionTimes.append((route, timeStamp, heading))
    except:
        pass
    
    return routePredictionTimes