当前位置: 首页>>代码示例>>Python>>正文


Python SimpleXMLWriter.XMLWriter类代码示例

本文整理汇总了Python中elementtree.SimpleXMLWriter.XMLWriter的典型用法代码示例。如果您正苦于以下问题:Python XMLWriter类的具体用法?Python XMLWriter怎么用?Python XMLWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了XMLWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: persist

    def persist(self):
        # Create an xml 
        outs = cStringIO.StringIO()
        w = XMLWriter(outs)
        root = w.start("parsedlog", submitter=self.__submitter)
        #self.parser.asXml(w)
        self.loot.asXml(w)
        self.attendance.asXml(w)
        self.kills.asXml(w)
        w.close(root)

        # Stuff the xml into an http post
        headers = {"Content-type": "application/xml",
                   "Accept": "text/plain"}

        #conn = httplib.HTTPConnection('beauty.quonic.net')
        #conn.request("POST", "/~erik/eqlogdb/submit.psp", outs.getvalue())
        conn = httplib.HTTPConnection('beauty.quonic.net')
        conn.request("POST", "/~erik/eqlogdb/submit.psp", outs.getvalue())
        response = conn.getresponse()
        if response.status == 200:
                self.loot.clear()
                self.attendance.clear()
                self.kills.clear()
        print response.read()
        conn.close()
开发者ID:easel,项目名称:gamestats,代码行数:26,代码来源:logparse.py

示例2: project_save1

def project_save1(tree):
    f = open('resar.xml', 'w')
    w = XMLWriter(f)
    html = w.start("data")
    w.element("empresa", '"' + tree.GetItemText(tree.GetRootItem(), 0) + '"')
    w.start('items')

    def printChildren(tree, treeItem):
        subItem = tree.GetFirstChild(treeItem)[0]
        name = tree.GetItemText(treeItem, 1)
        index = tree.GetItemText(treeItem, 0)
        try:
            parent = tree.GetItemText(tree.GetItemParent(treeItem), 1)
        except Exception:
            parent = 'root'

        if not subItem.IsOk():
            w.element("item", nombre=name, indice=index, parent=parent)

        else:
            w.element("item", nombre=name, indice=index, parent='root')

        while subItem.IsOk():
            printChildren(tree, subItem)
            subItem = tree.GetNextSibling(subItem)

    printChildren(tree, tree.GetRootItem())
   
    w.end('items')
    w.close(html)
    f.close()
开发者ID:moqca,项目名称:Legajos,代码行数:31,代码来源:project_handle.py

示例3: asXml

 def asXml(self):
     outs = cStringIO.StringIO()
     w = XMLWriter(outs)
     root = w.start("parsedlog", submitter=self.myname)
     self.fights.asXml(w)
     self.loot.asXml(w)
     self.attendance.asXml(w)
     self.kills.asXml(w)
     w.close(root)
     return str(outs.getvalue())
开发者ID:easel,项目名称:gamestats,代码行数:10,代码来源:parser.py

示例4: main

def main():
    dimension = sys.argv[1]
    min_count = int(sys.argv[2])
    engine_response = _json_post('%s/ws/query' % (ENGINE_URL), ENGINE_QUERY % {'dimension':dimension, 'min_count': min_count})
    facets = engine_response['facets'][dimension]['childIds']
    w = XMLWriter(sys.stdout)
    w.start("dimension", {'id': dimension, 'type': 'tree'})
    for facet in facets:
        w.start('element', {'id': facet, '_count':str(engine_response['facets'][dimension]['data'][facet]['count'])})
        w.end('element')
    w.end('dimension')
开发者ID:shebiki,项目名称:freebase-movies,代码行数:11,代码来源:facet_to_dimension.py

示例5: tagcloudxml

def tagcloudxml(request):
    xml = cStringIO.StringIO()
    w = XMLWriter(xml)
    tags = w.start("tags")
    for tag in tagcloud():
        w.element("a",
            text=tag['tag'],
            attrs={'href': "http://www.bhamtechevents.org/browse_events/%s".format(tag['tag']),
                   'title': "%s topics".format(tag["count"]), 'rel': "tag",
                   'style': "font-size: %s".format(tag["size"])}
        )
    w.end()
    w.close(tags)
    w.flush()
    return HttpResponse(xml.read())
开发者ID:Nonpython,项目名称:BHamTechEvents,代码行数:15,代码来源:shared.py

示例6: __init__

    def __init__(self, filename):
        BaseReporter.__init__(self)

        from cStringIO import StringIO
        self._sio = StringIO()
        from elementtree.SimpleXMLWriter import XMLWriter
        self.writer = XMLWriter(self._sio, "utf-8")
        self.filename = filename

        self.test_starts = {}
开发者ID:algard,项目名称:testoob,代码行数:10,代码来源:html_standalone.py

示例7: main

def main():
    genre_objects = json.load(sys.stdin)
    registry = {}
    for obj in genre_objects:
        registry[obj['id']] = obj

    _validate_parent_child_relationships(registry)

    top_level = [obj for obj in genre_objects if len(obj['_parent_ids']) == 0]

    touched = set()
    paths = set()

    w = XMLWriter(sys.stdout)
    w.start("dimension", {'id':'genre', 'type':'tree'})
    for obj in top_level:
        process_genre(w, obj, '', registry, touched, paths)
    w.end('dimension')

    _assert_all_visited(registry, touched)
开发者ID:shebiki,项目名称:freebase-movies,代码行数:20,代码来源:json_to_tree_dimension.py

示例8: __init__

    def __init__(self):
        BaseReporter.__init__(self)

        from cStringIO import StringIO
        self._sio = StringIO()
        try:
            from elementtree.SimpleXMLWriter import XMLWriter
        except ImportError:
            from testoob.compatibility.SimpleXMLWriter import XMLWriter
        self.writer = XMLWriter(self._sio, "utf-8")

        self.test_starts = {}
开发者ID:algard,项目名称:testoob,代码行数:12,代码来源:xml.py

示例9: __call__

    def __call__(self,options):
        """Make .tex file for JOB"""
        ret,jlist,base,jobspecfile,order,jjspec = e4t.cli.select_jobs_from_jobfile(options.jobfile)

        def xmloutjobs(w,name,*args,**kw):
            (datareqs,processors,outputs) = e4t.cli.get_elem_configs(*args,**kw)
            cfg = e4t.cli._read_cfgfile(kw,'OUTPUT',name)
            _cfgs = (kw, cfg)
            if cfg:
                # pprint(cfg)
                cfg = udict(cfg)
                cfg.remove('^__.*')
                cfg = ldict([ (k.replace(' ','_'),v) for k,v in cfg.items()])
                w.start("job",name=name,**ldict(cfg))
                w.end("job")

        formats = options.options.xget('FORMAT','XML')            

        from elementtree.SimpleXMLWriter import XMLWriter
        from StringIO import StringIO
        myxml = StringIO()
        w = XMLWriter(myxml)

        for part,jobs in jlist.items():        
            w.start('index', name=part )
            
            for j,k in jobs:
                if k['kind'] in ('table','figure'):
                    xmloutjobs(w,j,**k)

            w.end('index')

            ret = myxml.getvalue()

            xmls = dom.parseString(ret) # or xml.dom.minidom.parseString(xml_string)

            pp = Postprocessor(options=options)
            pp.output(False,xmls.toprettyxml(),'%s.xml'% part)
开发者ID:exedre,项目名称:e4t.new,代码行数:38,代码来源:export.py

示例10: open

    # convert to lat/lon
    if('X' in huisnr_fields):
        coordinates = projection.to_wgs84(huisnr_fields['X'], huisnr_fields['Y'])
    
        huisnr_fields['LAT'] = coordinates[0]
        huisnr_fields['LON'] = coordinates[1]
    else:
        huisnr_fields['LAT'] = ''
        huisnr_fields['LON'] = ''

fields = [ 'COMMUNE_NL', 'COMMUNE_FR', 'COMMUNE_DE', 'PKANCODE', 'STREET_NL', 'STREET_FR', 'STREET_DE', 'HUISNR', 'LAT', 'LON']

output = open(args.output_csv, 'w')
if(len(args.output_osm) > 0):
    w = XMLWriter(args.OUTFILE)
    w.start("osm", {"generator": "crab-tools" + str(__version__), "version": API_VERSION, "upload": "false"})
rec_str = ''
for field in fields:
    rec_str += field + ','
output.write(rec_str[:-1] + "\n")
            
for (huisnr_id, huisnr_fields) in huisnr_dic.items():
    rec_str = ''
    for field in fields:
        value = ''
        if(field in huisnr_fields):
            rec_str += str(huisnr_fields[field]) + ','
        else:
            rec_str += ','
    output.write(rec_str[:-1] + "\n")
开发者ID:xivk,项目名称:crab-tools,代码行数:30,代码来源:extract.py

示例11: XMLWriter

#Write datastreams manifest to XML
	#example datastream chunk
	'''
	<foxml:datastream CONTROL_GROUP="M" ID="ORIGINAL" STATE="A">
	    <foxml:datastreamVersion ID="ORIGINAL.0" MIMETYPE="image/jpeg" LABEL="Page#">
	        <foxml:contentLocation TYPE="URL">
	            <xsl:attribute name="REF">http://image.url/Sketches_and_scraps0000#.jpg</xsl:attribute>
	        </foxml:contentLocation>           
	    </foxml:datastreamVersion>
	</foxml:datastream>
	'''

fhand = item_path + "/" + item_ID + "_FOXML.xml"

w = XMLWriter(fhand, encoding="utf-8")
w.declaration()

#namespace dictionary
namespace={}
namespace['xmlns:foxml'] = "info:fedora/fedora-system:def/foxml#"
namespace['xmlns:xsi']="http://www.w3.org/2001/XMLSchema-instance"

manifest = w.start("ebook_item", namespace)

# iterate through parent collections and create <collection> elements for each
for collection_name in collections:
	w.element("collection", Template("$collection_name").substitute(collection_name=collection_name))

w.element("PID_prefix", Template("$PID_prefix").substitute(PID_prefix=PID_prefix))
w.element("book_title", Template("$item_ID").substitute(item_ID=item_ID))
开发者ID:ghukill,项目名称:fedora_utilities,代码行数:30,代码来源:ebook_XML_manifest_create.py

示例12: write_keymap

def write_keymap(keymap, filename):
  contexts = list(set([ c for c,a,k in keymap ]))
  actions  = list(set([ a for c,a,k in keymap ]))
  
  w = XMLWriter(filename, "utf-8")
  doc = w.start("keymap")
  
  for context in contexts:
    w.start(context)
    w.start("keyboard")
    for c,a,k in keymap:
      if c==context:
        w.element("key", a, id=k)
    w.end()
    w.end()
  w.end()
  w.close(doc)
开发者ID:curtisgibby,项目名称:xbmc-addon-keymap-config,代码行数:17,代码来源:io.py

示例13: main

def main():
    fout_name = os.path.join(data_dir, "geo_coordinates.xml")
    fout = open(fout_name, "w")
    w = XMLWriter(fout)

    w.start("root")
    f_name = os.path.join(data_dir, "crime_geo_coordinates.txt")
    with open(f_name) as f:
        for line in f:
            lat = str(line.split(",")[0])
            lng = str(line.split(",")[1])

            w.start('dataelement')
            w.element('text', "")
            w.start("geodata")
            w.element("latitude", lat)
            w.element("longitude", lng)
            w.end("geodata")
            w.end("dataelement")
            
    w.end("root")
开发者ID:jananzhu,项目名称:tourismApp,代码行数:21,代码来源:crime_geo_toXML.py

示例14: main


#.........这里部分代码省略.........
            elif key == Key.right:
                params['status'] = Status.skip
            elif key == Key.left:
                params['status'] = Status.back
            elif key == Key.backspace:
                params['status'] = Status.remove
            elif Key.char(key, '1') and cfg.dual_mode:
                params['status'] = Status.still
                lens = Theta.Left
            elif Key.char(key, '2') and cfg.dual_mode:
                params['status'] = Status.still
                lens = Theta.Right
            
        # catch exit status
        if params['status'] == Status.stop:
            print "\nprocess aborted!"
            break
        
        # write data
        if params['status'] == Status.record \
                and len(trainer_points[lens]) != max_clicks: # TODO: does this disable recording clicks on the last frame
                
            if dataQuality == 0:
                trainer_points[lens][in_vid.at()] = (params['pos'], in_csv.row()[2:5], in_csv.row()[8:10])
            params['status'] = Status.skip
        
        # or remove it
        elif params['status'] == Status.remove \
                and in_vid.at() in trainer_points[lens]:
            del trainer_points[lens][in_vid.at()]
            print "\nremoved dot"
        
        # load next csv frame
        if params['status'] == Status.skip:
            if in_vid.next():
                in_csv.next()
            else:
                write_xml = True
                print "\nend of video: {}/{}".format(in_vid.at() -1, mark_out -1)
                break
        
        # or load previous csv frame
        elif params['status'] == Status.back:
            if in_vid.back():
                in_csv.back()
        
        # reset status
        params['status'] = Status.wait
    
    # clean up
    cv2.destroyAllWindows()
    
    
    ## write xml
    if write_xml:
        out_xml = XMLWriter(args[3])
        out_xml.declaration()
        doc = out_xml.start("TrainingSet")
        
        # source information
        out_xml.start("video", mark_in=str(mark_in), mark_out=str(mark_out))
        out_xml.data(os.path.basename(args[1]))
        out_xml.end()
        out_xml.element("csv", os.path.basename(args[2]))
        
        # training point data
        for lens in trainer_points:
            if lens == Theta.Right:
                out_xml.start("buttonside", points=str(len(trainer_points[lens])))
            elif lens == Theta.Left:
                out_xml.start("backside", points=str(len(trainer_points[lens])))
            else: # non dualmode
                out_xml.start("frames", points=str(len(trainer_points[lens])))
            
            for i in trainer_points[lens]:
                pos, row, markers = trainer_points[lens][i]
                x, y = pos
                
                out_xml.start("frame", num=str(i))
                out_xml.element("plane", 
                                x=str(x), 
                                y=str(y))
                out_xml.element("vicon", 
                                x=str(row[0]), y=str(row[1]), z=str(row[2]))
                out_xml.element("visibility", 
                                visibleMax=str(markers[0]), 
                                visible=str(markers[1]))
                out_xml.end()
                
            out_xml.end() # frames
        
        # clean up
        out_xml.close(doc)
        
        print "Data was written."
    else:
        print "No data was written"
    
    print "\nDone."
    return 0
开发者ID:gwillz,项目名称:EagleEye,代码行数:101,代码来源:trainer.py

示例15: installerLog

def installerLog(package_details):
    '''
    This module writes the required fields of a package to a temporary 
    XML file which is then appended to the list of installedLog.xml.
    Right now - only name and version written to the installedLog.xml.
    '''
    
    #package_details contain all the info about the package
    w = XMLWriter('tempholder.xml')
    xml = w.start("xml")
    w.start("Package")
    w.element("name", package_details[0])
    w.element("version", package_details[1])
    #w.element("architecture", package_details[2])
    #w.element("short-description",package_details[3])
    #w.element("installed",package_details[4])
    #w.element("long-description",package_details[4])
    #-----^basic logging data above^------
    #w.element("section",package_details[5])
    #w.element("installed-size",package_details[6])
    #w.element("maintainer",package_details[7])
    #w.element("original-maintainer",package_details[8])
    #w.element("replaces",package_details[9])
    #w.element("provides",package_details[10])
    #w.element("pre-depends",package_details[11])
    #w.element("depends",package_details[5])
    #w.element("recomends",package_details[13])
    #w.element("suggests",package_details[14])
    #w.element("conflicts",package_details[15])
    #w.element("filename",package_details[16])
    #w.element("size",package_details[17])
    #w.element("md5sum",package_details[18])
    #w.element("homepage",package_details[19])
    w.end()
    w.close(xml)
开发者ID:pombredanne,项目名称:winlibre_pm,代码行数:35,代码来源:installerXMLLog.py


注:本文中的elementtree.SimpleXMLWriter.XMLWriter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。