ShayHill / docx2python

Extract docx headers, footers, (formatted) text, footnotes, endnotes, properties, and images.
https://docx2python.readthedocs.io/en/latest/
MIT License
157 stars 35 forks source link

File is not closing #35

Closed hildermesmedeiros closed 1 year ago

hildermesmedeiros commented 2 years ago

from docx2python import docx2python
docx2python(path_to_docx)

This simple cod it will keep the file open. I sugest to implement a del statetment in docx_reader.py

something like: def del(self): self.__zipf.close()

it will solve it.

ShayHill commented 2 years ago

Thank you. I will implement this in January.

From: Hildermes José Medeiros Filho @.> Sent: Wednesday, June 22, 2022 8:06 AM To: ShayHill/docx2python @.> Cc: Subscribed @.***> Subject: [ShayHill/docx2python] File is not closing (Issue #35)

from docx2python import docx2python docx2python(path_to_docx)

This simple cod it will keep the file open. I sugest to implement a del statetment in docx_reader.py

something like: def del(self): self.__zipf.close()

it will solve it.

— Reply to this email directly, view it on GitHubhttps://github.com/ShayHill/docx2python/issues/35, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADAKIE4IVZERPZOGRCIF5ETVQMFUVANCNFSM5ZQE77ZA. You are receiving this because you are subscribed to this thread.Message ID: @.**@.>>

albertogomcas commented 2 years ago

Workaround, for those that need to fix it without touching docx2python code:

doc = docx2python(file_path)
...
doc.docx_reader.zipf.fp.close()
ShayHill commented 2 years ago

Thank you for supplying this. Will update with an internal fix in January.

Sent from my iPhone

On Jul 25, 2022, at 01:08, Alberto Gomez-Casado @.***> wrote:



Workaround, for those that need to fix it without touching docx2python code:

doc = docx2python(file_path) ... doc.docx_reader.zipf.fp.close()

— Reply to this email directly, view it on GitHubhttps://github.com/ShayHill/docx2python/issues/35#issuecomment-1193620303, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADAKIEZVNJZIMYTMIAOYDQLVVYVMXANCNFSM5ZQE77ZA. You are receiving this because you commented.Message ID: @.***>

ShayHill commented 1 year ago

commit 361485ffdc3051c5008b65e8f02ee02796337d64 (HEAD -> master, tag: 2.4.0, origin/master, origin/dev, origin/HEAD, dev) Author: Shay Hill shay_public@hotmail.com Date: Mon Jan 23 11:16:49 2023 -0600

bump: version 2.3.0 → 2.4.0

commit 742ef648b6b57f310ce8f5955a19d7651849a87d Author: Shay Hill shay_public@hotmail.com Date: Mon Jan 23 09:12:14 2023 -0600

feat: add context manager protocol

The zipfile object opened by DocxReader can now be closed with
`DocxReader.close()` or `DocxContent.close()` or `with DocxReader() ...:` or
`with docx2python() ...:`

closes issue #35 File is not closing