Changeset 71:e85e3e1854c0
- Timestamp:
- 11/07/08 10:00:06 (16 months ago)
- Author:
- Nicolas ?vrard <nicoe@…>
- Branch:
- default
- Message:
-
Adapt opendocument.py to avoid name clash with genshi interface
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r69
|
r71
|
|
| 89 | 89 | It adds genshi directives and finds the inner docs. |
| 90 | 90 | """ |
| 91 | | inzip = zipfile.ZipFile(self.filepath) |
| 92 | | content = inzip.read('content.xml') |
| 93 | | styles = inzip.read('styles.xml') |
| | 91 | zf = zipfile.ZipFile(self.filepath) |
| | 92 | content = zf.read('content.xml') |
| | 93 | styles = zf.read('styles.xml') |
| 94 | 94 | |
| 95 | 95 | template = super(Template, self) |
| 96 | | content = template._parse(self.add_directives(content), encoding) |
| 97 | | styles = template._parse(self.add_directives(styles), encoding) |
| | 96 | content = template._parse(self.insert_directives(content), encoding) |
| | 97 | styles = template._parse(self.insert_directives(styles), encoding) |
| 98 | 98 | content_files = [('content.xml', content)] |
| 99 | 99 | styles_files = [('styles.xml', styles)] |
| … |
… |
|
| 102 | 102 | doc = self.inner_docs.pop() |
| 103 | 103 | c_path, s_path = doc + '/content.xml', doc + '/styles.xml' |
| 104 | | content = inzip.read(c_path) |
| 105 | | styles = inzip.read(s_path) |
| | 104 | content = zf.read(c_path) |
| | 105 | styles = zf.read(s_path) |
| 106 | 106 | |
| 107 | | c_parsed = template._parse(self.add_directives(inzip.read(c_path)), |
| | 107 | c_parsed = template._parse(self.insert_directives(zf.read(c_path)), |
| 108 | 108 | encoding) |
| 109 | | s_parsed = template._parse(self.add_directives(inzip.read(s_path)), |
| | 109 | s_parsed = template._parse(self.insert_directives(zf.read(s_path)), |
| 110 | 110 | encoding) |
| 111 | 111 | content_files.append((c_path, c_parsed)) |
| 112 | 112 | styles_files.append((s_path, s_parsed)) |
| 113 | 113 | |
| 114 | | inzip.close() |
| | 114 | zf.close() |
| 115 | 115 | parsed = [] |
| 116 | 116 | for fpath, fparsed in content_files + styles_files: |
| … |
… |
|
| 120 | 120 | return parsed |
| 121 | 121 | |
| 122 | | def add_directives(self, content): |
| | 122 | def insert_directives(self, content): |
| 123 | 123 | """adds to genshi directives, handle the images and the innerdocs. |
| 124 | 124 | """ |