OpenLayers OpenLayers

Changeset 7128

Show
Ignore:
Timestamp:
05/09/08 16:29:07 (8 months ago)
Author:
tschaub
Message:

sort examples by modified time and add atom:updated element

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/tools/exampleparser.py

    r7127 r7128  
    55import re 
    66import urllib2 
     7import time 
    78from xml.dom.minidom import Document 
    89 
     
    8788    feed = doc.createElementNS("http://www.w3.org/2005/Atom", "feed") 
    8889    for example in examples: 
     90        s = os.stat("../examples/" + example["example"]) 
     91        example["modified"] = s.st_mtime 
     92     
     93    examples.sort(key=lambda x:x["modified"]) 
     94    for example in sorted(examples, key=lambda x:x["modified"], reverse=True): 
    8995        entry = doc.createElementNS("http://www.w3.org/2005/Atom", "entry") 
    9096         
     
    100106        summary.appendChild(doc.createTextNode(example["shortdesc"] or example["example"])) 
    101107        entry.appendChild(summary) 
     108         
     109        updated = doc.createElementNS("http://www.w3.org/2005/Atom", "updated") 
     110        updated.appendChild(doc.createTextNode( 
     111            time.strftime("%Y-%m-%dT%I:%M:%SZ",time.gmtime(example["modified"])))) 
     112        entry.appendChild(updated) 
    102113         
    103114        feed.appendChild(entry) 
     
    183194    atom = open('../examples/example-list.xml','w') 
    184195    doc = createFeed(exampleList) 
    185     atom.write(doc.toprettyxml("    ")) 
     196    atom.write(doc.toxml()) 
    186197    atom.close() 
    187198