Created
May 12, 2012 03:52
-
-
Save rmzelle/2664018 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python script for additional style validation | |
# Author: Rintze M. Zelle | |
# Version: 2011-12-17 | |
# * Requires lxml library (http://lxml.de/) | |
# | |
# Add CC by-sa license | |
import os, glob, re, cgi | |
from lxml import etree | |
path = 'C:\Documents and Settings\zelle\My Documents\CSL\styles\\' | |
for independentStyle in glob.glob( os.path.join(path, 'annales.csl') ): | |
#print(os.path.basename(independentStyle)) | |
parser = etree.XMLParser(remove_blank_text=True) | |
style = etree.parse(independentStyle, parser) | |
styleElement = style.getroot() | |
try: | |
verbatimsStyle = styleElement.find(".//{http://purl.org/net/xbiblio/csl}rights").text | |
style = etree.tostring(style, pretty_print=True, xml_declaration=True, encoding="utf-8") | |
style = style.replace("'", '"', 4) | |
style = style.replace(u"\u00A0", "test") | |
f = open(independentStyle, 'w') | |
f.write ( style ) | |
f.close() | |
except: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment