~openerp-luxembourg/openobject-addons/6.0-luxembourg-localization-addons

« back to all changes in this revision

Viewing changes to account_payment_import_statement/parser/ing_lux_pdf.py

  • Committer: Xavier ALT
  • Date: 2012-02-01 11:48:59 UTC
  • Revision ID: xavier@thamini.com-20120201114859-xsv5g8g9anf4ccfp
[FIX] account_payment_import_statement: use real file for 'pdftotext' call

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
2
2
# -*- coding: utf-8 -*-
3
3
 
 
4
from __future__ import with_statement
4
5
import re
5
6
import sys
6
7
import codecs
77
78
        return len(periods) > 1
78
79
 
79
80
    def parse(self, f):
80
 
        p = Popen(['pdftotext', '-layout', '-', '-'], stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
81
 
        (out, err) = p.communicate(input=f.read())
 
81
        with tempfile.NamedTemporaryFile() as ftmp:
 
82
            ftmp.write(f.read())
 
83
            ftmp.flush()
 
84
            p = Popen(['pdftotext', '-layout', ftmp.name, '-'], stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True, bufsize=-1)
 
85
            (out, err) = p.communicate(input=f.read())
82
86
        self.parse_text(out)
83
87
        return self.get_statement_entries()
84
88