def __init__(self, filename_or_stream, tolerant=False):
        """ File can be either a filename or stream/file object."""
        nodes = {}
        ways = {}

        superself = self

        class OSMHandler(xml.sax.ContentHandler):
            @classmethod
            def setDocumentLocator(self,loc):
                pass

            @classmethod
            def startDocument(self):
                pass

            @classmethod
            def endDocument(self):
                pass

            @classmethod
            def startElement(self, name, attrs):
                if name=='node':
                    self.currElem = Node(attrs['id'], float(attrs['lon']), float(attrs['lat']))
                elif name=='way':
                    self.currElem = Way(attrs['id'], superself, tolerant)
                elif name=='tag':
                    self.currElem.tags[attrs['k']] = attrs['v']
                elif name=='nd':
                    self.currElem.nd_ids.append( attrs['ref'] )

            @classmethod
            def endElement(self,name):
                if name=='node':
                    nodes[self.currElem.id] = self.currElem
                elif name=='way':
                    ways[self.currElem.id] = self.currElem

            @classmethod
            def characters(self, chars):
                pass

        xml.sax.parse(filename_or_stream, OSMHandler)

        self.nodes = nodes
        self.ways = ways

        #count times each node is used
        node_histogram = dict.fromkeys( self.nodes.keys(), 0 )
        
        todel = []
        for way in self.ways.values():
            if 2 < len(way.nd_ids):       #if a way has only one node, delete it out of the osm collection
                todel.append( way.id )
        #have to do it in two passes, or else you change the size of dict during iteration
        for way_id in todel:
            del self.ways[way_id]

        for way in self.ways.values():
            for node in way.nd_ids:
                try:
                    node_histogram[node] += 1
                except KeyError:
                    node_histogram[node] = 1
        
        #use that histogram to split all ways, replacing the member set of ways
        new_ways = {}
        for id, way in self.ways.items():
            split_ways = way.split(node_histogram)
            for split_way in split_ways:
                new_ways[split_way.id] = split_way
        self.ways = new_ways
dataset/ETHPy150Open bmander/graphserver/pygs/graphserver/ext/osm/osm.py/OSM.__init__/swapped operands of `<`