summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2012-09-16 23:32:38 +0200
committerFlorian Bruhin <git@the-compiler.org>2012-09-16 23:32:38 +0200
commit2cfcf6ee526801afd6a0f986358191ae3c46487a (patch)
treebdda533f86a11af70ebc477e1a0dd4703b20a2fc
parent009efdb1eb7e6dd292db33791623be2e2ca0bf15 (diff)
downloadxojgrep-master.tar.gz
xojgrep-master.zip
Don't use a list for the contentHEADmaster
-rw-r--r--xojgrep.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/xojgrep.py b/xojgrep.py
index 4938b51..a162a4d 100644
--- a/xojgrep.py
+++ b/xojgrep.py
@@ -86,12 +86,10 @@ class XOJFile:
# TODO check if that works with a xournal file without texts
pagecount = len(self.tree.xpath('/xournal/page'))
for pn in range(1, pagecount + 1):
- pagecontent = []
texts = self.tree.xpath('/xournal/page[{}]//text'.format(pn))
for text in texts:
- pagecontent.append(text.text)
- if pagecontent:
- content.append((pn, pagecontent))
+ for line in text.split('\n'):
+ content.append((pn, line))
return content
@@ -109,8 +107,8 @@ class PDFFile:
for pn in range(0, pagecount):
page = self.doc.getPage(pn)
text = page.extractText()
- if text:
- content.append((pn + 1, [text]))
+ for line in text.split('\n'):
+ content.append((pn + 1, text))
return content
@@ -124,7 +122,7 @@ class TXTFile:
def getcontent(self):
content = []
for (ln, line) in enumerate(self.txtfile, 1):
- content.append((ln, [line.rstrip('\n')]))
+ content.append((ln, line.rstrip('\n')))
return content