Closed joshuajan closed 5 years ago
Thanks for this very interesting contribution ! Do you think that, with your PR, factur-x would work both in python2 and python3 ? Or would it only work in python3 ?
Not sure if it's due to the migration or not, yet, but I tried in Python 3.7.2, with the examples from http://fnfe-mpe.org/factur-x/ and it failed:
$ facturx-pdfextractxml --log-level=debug Facture_DOM_BASIC.pdf Facture_DOM_BASIC.pdf.xml
2019-01-11 00:02:47,172 [DEBUG] pdf_root={'/AF': IndirectObject(9, 0), '/Type': '/Catalog', '/Names': {'/EmbeddedFiles': {'/Names': ['factur-x.xml', IndirectObject(5, 0)]}}, '/OutputIntents': [IndirectObject(7, 0)], '/Metadata': IndirectObject(8, 0), '/Pages': IndirectObject(1, 0), '/PageMode': '/UseAttachments'}
2019-01-11 00:02:47,172 [DEBUG] embeddedfiles=['factur-x.xml', IndirectObject(5, 0)]
2019-01-11 00:02:47,172 [ERROR] No valid XML file found in the PDF
DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead [facturx-pdfextractxml:80]
2019-01-11 00:02:47,172 [WARNING] File Facture_DOM_BASIC.pdf.xml has not been created
Can confirm, it works with Python 2.7:
$ facturx-pdfextractxml --log-level=debug Facture_DOM_BASIC.pdf Facture_DOM_BASIC.pdf.xml
PdfReadWarning: PdfFileReader stream/file object is not in binary mode. It may not be read correctly. [pdf.py:1079]
2019-01-11 00:06:21,667 [DEBUG] pdf_root={'/AF': IndirectObject(9, 0), '/Type': '/Catalog', '/Names': {'/EmbeddedFiles': {'/Names': [u'factur-x.xml', IndirectObject(5, 0)]}}, '/OutputIntents': [IndirectObject(7, 0)], '/Pages': IndirectObject(1, 0), '/PageMode': '/UseAttachments', '/Metadata': IndirectObject(8, 0)}
2019-01-11 00:06:21,667 [DEBUG] embeddedfiles=[u'factur-x.xml', IndirectObject(5, 0)]
2019-01-11 00:06:21,667 [DEBUG] embeddedfiles_by_two=[(u'factur-x.xml', IndirectObject(5, 0))]
2019-01-11 00:06:21,667 [DEBUG] found filename=factur-x.xml
2019-01-11 00:06:21,668 [DEBUG] xml_file_dict={'/Type': '/Filespec', '/AFRelationship': '/Data', '/F': u'factur-x.xml', '/Desc': u'Factur-X Invoice', '/UF': u'factur-x.xml', '/EF': {'/F': IndirectObject(4, 0), '/UF': IndirectObject(4, 0)}}
2019-01-11 00:06:21,668 [INFO] A valid XML file factur-x.xml has been found in the PDF file
Oh, this is line 177 of facturx.py
, TypeError: 'zip' object is not subscriptable
.
Hello @JulienPalard I have update the code. and I have test the script both in python2 and python3.
Dear @alexis-via
Thanks for your job. We want to use the Chorus module in Odoo V12. And we have upgrade some module to V12. Here is the PR for factur-x py3.
Thank you.