Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Python の XUL パーサ / ソースコード

Python の XUL パーサ』のソースコード

import sys, glob, xmllib
import os, re
el_list = {}
w = open('res.html', 'w')

# Unfortunately, I had to put this hack in here to suppress the printing out of the resolved namespace: 
# "xmlns="https://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul window", etc.

def strip(snip):
	t = re.sub('https://.*?\s', '', snip)
	return t
  		
class XULParser(xmllib.XMLParser):
	def unknown_starttag(self, t, a):
		name = strip(t)
		if name not in el_list: el_list[name] = {}
		for attr,val in a.items():
			el_list[name][strip(attr)] = strip(val)
			
	def syntax_error(self, message):
		pass
	
p = XULParser()
  
cmd = 'dir /s /b *.xul'
CHROME_DIR = 'C:\Program Files\Netscape\Netscape 6\chrome' 
os.chdir(CHROME_DIR)
files = os.popen(cmd).readlines()
for file in files:
	file = file.strip()
	print '** ' + file + ' **'
	data = open(file).read()
	p.feed(data)
  	
w.write('<html><h3>Periodic Table of XUL Elements</h3>')
w.write('<table><style>.head {font-weight: bold; background-color: lightgrey;}</style>')
  
elements = el_list.keys()
elements.sort()
for item in elements:
	w.write('<tr><td class="head">' + item + '</td></tr>\n')
	for a in el_list[item]:
		w.write('<tr><td class="at">' + a + '</td>')
	
w.write('</table></html>\n')
w.close()

ドキュメントのタグと貢献者

 このページの貢献者: ethertank
 最終更新者: ethertank,