sort examples by modified time and add atom:updated element
git-svn-id: http://svn.openlayers.org/trunk/openlayers@7128 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
+12
-1
@@ -4,6 +4,7 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import urllib2
|
import urllib2
|
||||||
|
import time
|
||||||
from xml.dom.minidom import Document
|
from xml.dom.minidom import Document
|
||||||
|
|
||||||
missing_deps = False
|
missing_deps = False
|
||||||
@@ -86,6 +87,11 @@ def createFeed(examples):
|
|||||||
doc = Document()
|
doc = Document()
|
||||||
feed = doc.createElementNS("http://www.w3.org/2005/Atom", "feed")
|
feed = doc.createElementNS("http://www.w3.org/2005/Atom", "feed")
|
||||||
for example in examples:
|
for example in examples:
|
||||||
|
s = os.stat("../examples/" + example["example"])
|
||||||
|
example["modified"] = s.st_mtime
|
||||||
|
|
||||||
|
examples.sort(key=lambda x:x["modified"])
|
||||||
|
for example in sorted(examples, key=lambda x:x["modified"], reverse=True):
|
||||||
entry = doc.createElementNS("http://www.w3.org/2005/Atom", "entry")
|
entry = doc.createElementNS("http://www.w3.org/2005/Atom", "entry")
|
||||||
|
|
||||||
title = doc.createElementNS("http://www.w3.org/2005/Atom", "title")
|
title = doc.createElementNS("http://www.w3.org/2005/Atom", "title")
|
||||||
@@ -100,6 +106,11 @@ def createFeed(examples):
|
|||||||
summary.appendChild(doc.createTextNode(example["shortdesc"] or example["example"]))
|
summary.appendChild(doc.createTextNode(example["shortdesc"] or example["example"]))
|
||||||
entry.appendChild(summary)
|
entry.appendChild(summary)
|
||||||
|
|
||||||
|
updated = doc.createElementNS("http://www.w3.org/2005/Atom", "updated")
|
||||||
|
updated.appendChild(doc.createTextNode(
|
||||||
|
time.strftime("%Y-%m-%dT%I:%M:%SZ",time.gmtime(example["modified"]))))
|
||||||
|
entry.appendChild(updated)
|
||||||
|
|
||||||
feed.appendChild(entry)
|
feed.appendChild(entry)
|
||||||
|
|
||||||
doc.appendChild(feed)
|
doc.appendChild(feed)
|
||||||
@@ -182,7 +193,7 @@ if __name__ == "__main__":
|
|||||||
print "writing feed to ../examples/example-list.xml "
|
print "writing feed to ../examples/example-list.xml "
|
||||||
atom = open('../examples/example-list.xml','w')
|
atom = open('../examples/example-list.xml','w')
|
||||||
doc = createFeed(exampleList)
|
doc = createFeed(exampleList)
|
||||||
atom.write(doc.toprettyxml(" "))
|
atom.write(doc.toxml())
|
||||||
atom.close()
|
atom.close()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user