forked from citation-style-language/utilities
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsl-add-updated.py
More file actions
26 lines (21 loc) · 891 Bytes
/
csl-add-updated.py
File metadata and controls
26 lines (21 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Python script to add timestamp to style with empty updated field
# Author: Rintze M. Zelle
# Version: 2011-12-17
# * Requires lxml library (http://lxml.de/)
import os, glob, re
from lxml import etree
path = 'C:\Documents and Settings\zelle\My Documents\CSL\styles\dependent\\'
verbatims = {}
for independentStyle in glob.glob( os.path.join(path, '*.csl') ):
style = etree.parse(independentStyle)
styleElement = style.getroot()
updatedContent = None
updated = styleElement.find(".//{http://purl.org/net/xbiblio/csl}updated")
updatedContent = updated.text
if updatedContent == None:
updated.text = "2012-01-01T00:00:00+00:00"
style = etree.tostring(style, pretty_print=True, xml_declaration=True, encoding="utf-8")
style = style.replace("'", '"', 4)
f = open(independentStyle, 'w')
f.write ( style )
f.close()