示例#1
0
文件: comps.py 项目: TaRiven/snippets
def parseComps(path):
    handler = saxkit.StackedHandler((None, 'comps'), Comps())
    parser = xml.sax.make_parser()
    parser.setFeature(xml.sax.handler.feature_namespaces, True)
    parser.setContentHandler(handler)
    parser.parse(path)
    return handler.getRootElement()
示例#2
0
 def setUp(self):
     self.handler = saxkit.StackedHandler((SOAPENV, u'Envelope'),
                                          SoapMessage())
     parser = xml.sax.make_parser()
     parser.setFeature(xml.sax.handler.feature_namespaces, True)
     parser.setContentHandler(self.handler)
     parser.parse("sample/informbootstrap.xml")
     self.sm = self.handler.getRootElement()
示例#3
0
                    print "(Found one, but couldn't print it...)"
                    pass
                doc = couchdb.Document(_id=val.title,
                                       text=val.text,
                                       revinfo=val.revdata)
                if val.is_redirect:
                    doc['is_redirect'] = True
                if val.geo:
                    doc['geo'] = val.geo
                self.allDocs.append(doc)
                if len(self.allDocs) >= 10000:
                    self.commit()


if __name__ == '__main__':

    try:
        WAITING_FOR = DB.changes(since=(DB.info()['update_seq'] -
                                        1))['results'][0]['id']
        print "Waiting for", WAITING_FOR
    except:
        pass

    # Load seen titles
    handler = saxkit.StackedHandler((ROOT_NS, ROOT_EL), RootHandler())
    parser = xml.sax.make_parser()
    parser.setFeature(xml.sax.handler.feature_namespaces, True)
    parser.setContentHandler(handler)
    parser.parse(sys.stdin)
    sm = handler.getRootElement()