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)
    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
Exemple #3
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
Exemple #4
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
    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
Exemple #6
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)