def endElement(self, name):
        self.name_stack.pop()

        if name == 'StopPoint':
            try:
                # Classify metro stops according to their particular system
                if self.meta['stop-type'] == 'MET':
                    try:
                        entity_type, is_entrance = self.entity_types[self.meta['stop-type'] + ':' + self.meta['atco-code'][6:8]]
                    except __HOLE__:
                        entity_type, is_entrance = self.entity_types['MET']
                else:
                    entity_type, is_entrance = self.entity_types[self.meta['stop-type']]
            except KeyError:
                pass
            else:
                entity = self.add_stop(self.meta, entity_type, self.source, is_entrance)
                if entity:
                    self.entities.add(entity)
        
        elif name == 'StopAreaRef':
            self.stop_areas.append(self.meta['stop-area'])
            del self.meta['stop-area']
        
        elif name == 'StopArea':
            if self.areas != None:
                in_area = False
                for area in self.areas:
                    if self.meta['area-code'].startswith(area):
                        in_area = True
                if not in_area:
                    return
            
            sa, created = EntityGroup.objects.get_or_create(
                source=self.source,
                ref_code=self.meta['area-code'])
            sa.save()
            for lang_code, name in self.names.items():
                if lang_code is None: lang_code = 'en'
                set_name_in_language(sa, lang_code, title=name)
        
        elif name == 'CommonName':
            if self.lang not in self.names:
                self.names[self.lang] = self.meta['common-name']
        
        elif name == 'Name' and self.meta['name'] != '':
            if self.lang not in self.names:
                self.names[self.lang] = self.meta['name']
dataset/ETHPy150Open mollyproject/mollyproject/molly/apps/places/providers/naptan.py/NaptanContentHandler.endElement