Anonymous avatar Anonymous committed 7e2b89e

output odf

Comments (0)

Files changed (1)

 # coding:utf8
+
+# uses svn version from http://opendocumentfellowship.com/projects/odfpy
 import sys
 from urllib import urlopen
 from re import compile
 import re
 from warnings import warn
 from BeautifulSoup import BeautifulSoup
+from odf.opendocument import OpenDocumentText
+from odf.text import P, Span
+from odf.style import Style, TextProperties
+
 
 BASE_URL = 'http://www.assemblee-nationale.fr/13/amendements/1240/124%06d.asp'
 SOURCES = 'http://www.laquadrature.net/amendements.txt'
     s = s.replace('\r\n', '')
     s = re.sub('<br.*/?>', '\n', s)
     s = re.sub('<!--.*-->', '', s)
-    s = s.encode('latin1', 'xmlcharrefreplace')
+#    s = s.encode('latin1', 'xmlcharrefreplace')
     return s
 
 def single_finder(regex, flags=0):
     else:
         urls = [ url.strip() for url in urlopen(SOURCES)]
     # init amdts
+
+    textdoc = OpenDocumentText()
+    s = textdoc.styles
+    gras = Style(name="Gras", family="text")
+    propriete = TextProperties(fontweight="bold")
+    gras.addElement(propriete)
+    s.addElement(gras)
+
+    
+
     amdts = [ Amdt(url) for url in urls]
 
     #print them
     for amdt in amdts:
         from pprint import pprint
-        pprint(amdt.data)
+	p = P(text=(u"Amendement "), )
+	p.addElement(Span(stylename=gras, text=(u"%s, de %s" % (amdt.data["number"], amdt.data["author"]))))
+        textdoc.text.addElement(p)
+	p = P()
+	p.addElement(Span(text=(u"Détail : "),stylename=gras))
+	textdoc.text.addElement(p)
+	for detail in amdt.data["detail"]:
+	  p = P()
+          p.addElement(Span(text=(u"%s\r\n" % detail)))
+          textdoc.text.addElement(p)
+	  p = P()
+	  textdoc.text.addElement(p)
+	p.addElement(Span(stylename=gras, text=(u"Exposé : ")))
+	for expose in amdt.data["expose"]:
+	  p = P()
+          p.addElement(Span(text=(u"%s\n" % expose)))
+    	  textdoc.text.addElement(p)
+	  p = P()
+	  textdoc.text.addElement(p)
+	p = P()
+	textdoc.text.addElement(p)
+	pprint(amdt.data)
+    textdoc.save("amendements", True)
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.