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


Python XMLWriter.start方法代码示例

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


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

示例1: project_save1

# 需要导入模块: from elementtree.SimpleXMLWriter import XMLWriter [as 别名]
# 或者: from elementtree.SimpleXMLWriter.XMLWriter import start [as 别名]
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,代码行数:33,代码来源:project_handle.py

示例2: installerLog

# 需要导入模块: from elementtree.SimpleXMLWriter import XMLWriter [as 别名]
# 或者: from elementtree.SimpleXMLWriter.XMLWriter import start [as 别名]
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,代码行数:37,代码来源:installerXMLLog.py

示例3: createMetadata

# 需要导入模块: from elementtree.SimpleXMLWriter import XMLWriter [as 别名]
# 或者: from elementtree.SimpleXMLWriter.XMLWriter import start [as 别名]
def createMetadata(item_ID):
	# get number of files
	images = os.listdir("/processing/"+item_ID+"/images")
	leaf_count = len(images) - 1 #accounts for /thumbs directory in there		

	# get dimensions of cover and create cover image
	cover_path = Template('/processing/$item_ID/images/$item_ID').substitute(item_ID=item_ID) + "00001.jpg"
	im = Image.open(cover_path)
	width, height = im.size #returns tuple

	# generate cover thumbnail
	max_cover_width = 200
	max_cover_height = 200
	im.thumbnail((max_cover_width, max_cover_height), Image.ANTIALIAS)				
	im.save(Template('/processing/$item_ID/$item_ID').substitute(item_ID=item_ID) + "_cover.jpg")
	print "Cover created for",item_ID	

	# write to xml
	fhand = Template("/processing/$item_ID/$item_ID$suffix.xml").substitute(item_ID=item_ID, suffix="_metadata")
	w = XMLWriter(fhand, "utf-8")

	metadata = w.start("add")
	w.start("doc")
	w.element("field", Template("meta:$item_ID").substitute(item_ID=item_ID), name="id") 
	w.element("field", Template("$item_ID").substitute(item_ID=item_ID), name="ItemID") #no underscore for solr index in "ItemID"
	#creats overall ratio - height / width
	w.element("field", str(height), name="pheight")
	w.element("field", str(width), name="pwidth")
	w.element("field", str(leaf_count), name="leafs")
	w.element("field", Template("$item_ID").substitute(item_ID=item_ID), name="item_title") #how will we generate this? ItemID for now... 
	w.end() #closes <doc>

	w.close(metadata)
开发者ID:ghukill,项目名称:fedora_utilities,代码行数:35,代码来源:WSU-PDF_process_incoming_to_Fedora_152.py

示例4: main

# 需要导入模块: from elementtree.SimpleXMLWriter import XMLWriter [as 别名]
# 或者: from elementtree.SimpleXMLWriter.XMLWriter import start [as 别名]
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,代码行数:13,代码来源:facet_to_dimension.py

示例5: create_project

# 需要导入模块: from elementtree.SimpleXMLWriter import XMLWriter [as 别名]
# 或者: from elementtree.SimpleXMLWriter.XMLWriter import start [as 别名]
def create_project(name, path, template=None):
    os.mkdir(path)
    os.mkdir(os.path.join(path, 'bin'))
    os.mkdir(os.path.join(path, 'contabilidad'))
    os.mkdir(os.path.join(path, 'documentos'))
    f = open(os.path.join(path, 'bin','empresa.xml'), 'w')
    w = XMLWriter(f)
    html = w.start("data")
    w.element("empresa", '"' + name + '"')
    w.start('items')
    w.element('item', nombre=name, indice='', parent='root')
    w.end('items')
    w.close(html)
    f.close()
开发者ID:moqca,项目名称:Legajos,代码行数:16,代码来源:project_handle.py

示例6: to_xml

# 需要导入模块: from elementtree.SimpleXMLWriter import XMLWriter [as 别名]
# 或者: from elementtree.SimpleXMLWriter.XMLWriter import start [as 别名]
 def to_xml(self):
     from StringIO import StringIO
     myxml = StringIO()
     w = XMLWriter(myxml)
     w.start(self._kind.lower(), name=self._label )
     if self._m_title:    w.element("title", self._m_title )
     if self._m_subtitle: w.element("subtitle", self._m_subtitle )
     if self._m_num:      w.element("num", self._m_num )
     if self._m_source:   w.element("source", self._m_source )
     self.to_xml_body(w)
     w.end(self._kind.lower())
     ret = myxml.getvalue()
     myxml.close()
     return ret
开发者ID:exedre,项目名称:e4t.new,代码行数:16,代码来源:layout.py

示例7: run1

# 需要导入模块: from elementtree.SimpleXMLWriter import XMLWriter [as 别名]
# 或者: from elementtree.SimpleXMLWriter.XMLWriter import start [as 别名]
def run1():
	x = XMLWriter("test.xml")

	musicLibrary = x.start("musciLibrary")

	x.start("song")
	x.element("id", "2")
	x.element("title", "Jigga What/Faint")
	x.element("artist", "Linkin Park/Jay Z")
	x.element("year", "2004")
	x.element("trackNumber", "3")
	x.element("totalTracks", "6")
	x.element("genre", "Rap/Nu Metal")
	x.end("song")
	x.close(musicLibrary)
开发者ID:atdalman,项目名称:music-stats,代码行数:17,代码来源:parseXML.py

示例8: post

# 需要导入模块: from elementtree.SimpleXMLWriter import XMLWriter [as 别名]
# 或者: from elementtree.SimpleXMLWriter.XMLWriter import start [as 别名]
def post():
   try:
      d = request.form['thedata']
      ds = json.loads(d)['activity']
      stime = ds['startTimeUtc']
      stime = dateutil.parser.parse(stime)
      points = ds['geo']['waypoints']
      name = ds['name']

      f = StringIO.StringIO()
      w = XMLWriter(f)
      gpx_attribs = {"version":"1.1",
                        "creator":"unrealduck.com",
                        "xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance",
                        "xmlns:gpxtpx":"http://www.garmin.com/xmlschemas/TrackPointExtension/v1",
                        "xmlns":"http://www.topografix.com/GPX/1/1",
                        "xsi:schemaLocation":"http://www.topografix.com/GPX/1/1 http://www.topografix.com/gpx/1/1/gpx.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd"}
      gpx = w.start("gpx", gpx_attribs)
      w.start("metadata")
      w.element("name", name)
      w.element("time", str(stime).replace(" ", "T"))
      w.element("desc", "Import from nikeplus.com")
      w.end()

      w.start("trk")
      w.element("name", name)
      w.start("trkseg")

      for i,pt in zip(range(len(points)), points):            
         time = stime + datetime.timedelta(seconds=i)
         w.start("trkpt", lon=str(pt['lon']), lat=str(pt['lat']))
         w.element("ele", str(pt['ele']))
         w.element("time", str(time).replace(" ", "T"))
         w.end()
                     
      w.end()
      w.end()
         
      w.close(gpx)

      filename = '_'.join([ds['activityType'], ds['deviceType'], str(stime.date()), str(stime.time())])
      response = make_response("<?xml version=\"1.0\" ?>"+f.getvalue())
      response.headers['Content-Type'] = 'application/gpx+xml'         
      response.headers['Content-Disposition'] = 'attachment; filename='+filename+'.gpx'                 
      return response
      
   except KeyError:
      print "KeyError"
      return make_response("KeyError")
   except:
      print "UnexpectedError"
      print sys.exc_info()[0]
      return make_response("Unexpected error")
开发者ID:jussini,项目名称:np2gpx,代码行数:55,代码来源:np2gpx.py

示例9: persist

# 需要导入模块: from elementtree.SimpleXMLWriter import XMLWriter [as 别名]
# 或者: from elementtree.SimpleXMLWriter.XMLWriter import start [as 别名]
    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,代码行数:28,代码来源:logparse.py

示例10: write_keymap

# 需要导入模块: from elementtree.SimpleXMLWriter import XMLWriter [as 别名]
# 或者: from elementtree.SimpleXMLWriter.XMLWriter import start [as 别名]
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,代码行数:19,代码来源:io.py

示例11: asXml

# 需要导入模块: from elementtree.SimpleXMLWriter import XMLWriter [as 别名]
# 或者: from elementtree.SimpleXMLWriter.XMLWriter import start [as 别名]
 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,代码行数:12,代码来源:parser.py

示例12: main

# 需要导入模块: from elementtree.SimpleXMLWriter import XMLWriter [as 别名]
# 或者: from elementtree.SimpleXMLWriter.XMLWriter import start [as 别名]
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,代码行数:22,代码来源:json_to_tree_dimension.py

示例13: process

# 需要导入模块: from elementtree.SimpleXMLWriter import XMLWriter [as 别名]
# 或者: from elementtree.SimpleXMLWriter.XMLWriter import start [as 别名]
    def process(self, args):
        # Perform any base class processing.
        if not super(NfoProcess, self).process(args):
            return

        # If we don't have an output parameter, we figure it out from
        # the input filename.
        output = args.output

        if not output:
            output = os.path.splitext(args.tmdb)[0] + ".nfo"

        # Check to see if the file exists.
        if os.path.isfile(output) and not args.force:
            print "Cannot overwrite file: " + output
            return False

        # Open up the output file.
        xml = open(output, 'w')
        xml.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")

        w = XMLWriter(xml, 'utf-8')
        tag = w.start("movie", ThumbGen="1")
        w.element("hasrighttoleftdirection", "false")
        w.element("title", self.movie['title'])
        w.element("originaltitle", self.movie['original_title'])
        w.element("filename", os.path.splitext(args.tmdb)[0] + ".mp4")
        w.element("tagline", self.movie['tagline'])
        w.element("releasedate", self.movie['release_date'])
        w.element("id", self.movie['imdb_id'])
        w.element("runtime", format(self.movie['runtime']))
        w.element("plot", self.movie['overview'])

        # Write out the genres.
        w.start("genre")

        for genre in self.movie['genres']:
            w.element("name", genre['name'])

        w.end()

        # Media information
        w.start("mediainfo")
        w.start("Resolution")
        w.element("Flag", "Resolution_480p")
        w.end()
        w.element("resolution", "480P")
        w.end()

        # Finish up the document.
        w.end()
        w.close(tag)
        xml.close()

        # Report that we created the file.
        self.log.info("Created " + output)
开发者ID:dmoonfire,项目名称:mfgames-media-python,代码行数:58,代码来源:themoviedb.py

示例14: _record_key

# 需要导入模块: from elementtree.SimpleXMLWriter import XMLWriter [as 别名]
# 或者: from elementtree.SimpleXMLWriter.XMLWriter import start [as 别名]
def _record_key():
    	dialog = KeyListener()
    	dialog.doModal()
    	key = dialog.key
    	del dialog
	w = XMLWriter(twitter_file, "utf-8")
	doc = w.start("keymap")
	w.start("global")
	w.start("keyboard")
        w.element("key", "addon.opensettings(script.service.twitter)", id=str(key))
	w.end()
	w.end()
	w.start("fullscreenvideo")
	w.start("keyboard")
	w.element("key", "addon.opensettings(script.service.twitter)", id=str(key))
	w.end()
	w.end()
	w.end()
	w.close(doc)
开发者ID:Romans-I-XVI,项目名称:script.service.twitter,代码行数:21,代码来源:default.py

示例15: __call__

# 需要导入模块: from elementtree.SimpleXMLWriter import XMLWriter [as 别名]
# 或者: from elementtree.SimpleXMLWriter.XMLWriter import start [as 别名]
    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,代码行数:40,代码来源:export.py


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