Skip to content

Commit d3b6a43

Browse files
Merge pull request #289 from TeamMsgExtractor/next-release
v0.36.3
2 parents 20aa32e + f3c8eef commit d3b6a43

File tree

11 files changed

+40
-14
lines changed

11 files changed

+40
-14
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
custom: ['https://www.buymeacoffee.com/DestructionE']
1+
custom: ['https://www.buymeacoffee.com/DestructionE', 'https://www.patreon.com/DestructionE']
12.2 KB
Loading
1.46 KB
Binary file not shown.

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
**v0.36.3**
2+
* Added an option to skip the body if it could not be found, rather than throwing an error. This will cause no file to be made for it in the event no valid body exists. For the save functions, this option is `skipBodyNotFound` and from the command line the option is `--skip-body-not-found`.
3+
* Fixed a bug that caused contacts to save the business phone with two colons instead of 1.
4+
15
**v0.36.2**
26
* [[TeamMsgExtractor #286](https://github.com/TeamMsgExtractor/msg-extractor/issues/286)] Fix missing import.
37

README.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ refer to the usage information provided from the program's help dialog:
8787
--raw Sets whether the output should be raw. If this is not possible, will error.
8888
--rtf Sets whether the output should be RTF. If this is not possible, will error.
8989
--allow-fallback Tells the program to fallback to a different save type if the selected one is not possible.
90+
--skip-body-not-found Skips saving the body if the body cannot be found, rather than throwing an error.
9091
--zip ZIP Path to use for saving to a zip file.
9192
--attachments-only Specify to only save attachments from an msg file.
9293
--no-folders When used with --attachments-only, stores everything in the location specified by --out. Incompatible with --out-name.
@@ -226,8 +227,8 @@ your access to the newest major version of extract-msg.
226227
.. |License: GPL v3| image:: https://img.shields.io/badge/License-GPLv3-blue.svg
227228
:target: LICENSE.txt
228229

229-
.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.36.2-blue.svg
230-
:target: https://pypi.org/project/extract-msg/0.36.2/
230+
.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.36.3-blue.svg
231+
:target: https://pypi.org/project/extract-msg/0.36.3/
231232

232233
.. |PyPI2| image:: https://img.shields.io/badge/python-3.6+-brightgreen.svg
233234
:target: https://www.python.org/downloads/release/python-367/

extract_msg/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2828

2929
__author__ = 'Destiny Peterson & Matthew Walker'
30-
__date__ = '2022-08-12'
31-
__version__ = '0.36.2'
30+
__date__ = '2022-08-29'
31+
__version__ = '0.36.3'
3232

3333
import logging
3434

extract_msg/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def main() -> None:
6767
'pdf': args.pdf,
6868
'preparedHtml': args.preparedHtml,
6969
'rtf': args.rtf,
70+
'skipBodyNotFound': args.skipBodyNotFound,
7071
'skipEmbedded': args.skipEmbedded,
7172
'skipNotImplemented': args.skipNotImplemented,
7273
'useMsgFilename': args.useFilename,

extract_msg/contact.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ def strListToStr(inp : Union[str, List[str]]):
714714
'IM Address': self.instantMessagingAddress,
715715
},
716716
'-phone numbers-': {
717-
'Business:': self.businessTelephoneNumber,
717+
'Business': self.businessTelephoneNumber,
718718
'Business 2': strListToStr(self.businessTelephone2Number),
719719
'Assistant': self.assistantTelephoneNumber,
720720
'Company Main Phone': self.companyMainTelephoneNumber,

extract_msg/message_base.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,8 @@ def save(self, **kwargs):
659659
:param attachmentsOnly: Turns off saving the body and only saves the
660660
attachments when set.
661661
:param skipAttachments: Turns off saving attachments.
662+
:param skipBodyNotFound: Suppresses errors if no valid body could be
663+
found, simply skipping the step of saving the body.
662664
:param charset: If the html is being prepared, the charset to use for
663665
the Content-Type meta tag to insert. This exists to ensure that
664666
something parsing the html can properly determine the encoding (as
@@ -697,6 +699,9 @@ def save(self, **kwargs):
697699
attachOnly = kwargs.get('attachmentsOnly', False)
698700
# Track if we are skipping attachments.
699701
skipAttachments = kwargs.get('skipAttachments', False)
702+
# Track if we should skip the body if no valid body is found instead of
703+
# raising an exception.
704+
skipBodyNotFound = kwargs.get('skipBodyNotFound', False)
700705

701706
if pdf:
702707
kwargs['preparedHtml'] = True
@@ -810,21 +815,30 @@ def save(self, **kwargs):
810815
useHtml = True
811816
fext = 'html'
812817
elif not allowFallback:
813-
raise DataNotFoundError('Could not find the htmlBody.')
818+
if skipBodyNotFound:
819+
fext = None
820+
else:
821+
raise DataNotFoundError('Could not find the htmlBody.')
814822

815823
if pdf:
816824
if self.htmlBody:
817825
usePdf = True
818826
fext = 'pdf'
819827
elif not allowFallback:
820-
raise DataNotFoundError('Count not find the htmlBody to convert to pdf.')
828+
if skipBodyNotFound:
829+
fext = None
830+
else:
831+
raise DataNotFoundError('Count not find the htmlBody to convert to pdf.')
821832

822833
if rtf or (html and not useHtml) or (pdf and not usePdf):
823834
if self.rtfBody:
824835
useRtf = True
825836
fext = 'rtf'
826837
elif not allowFallback:
827-
raise DataNotFoundError('Could not find the rtfBody.')
838+
if skipBodyNotFound:
839+
fext = None
840+
else:
841+
raise DataNotFoundError('Could not find the rtfBody.')
828842
else:
829843
# This was the last resort before plain text, so fall
830844
# back to that.
@@ -837,10 +851,13 @@ def save(self, **kwargs):
837851
# was found but was empty that is considered valid, so we
838852
# specifically check against None.
839853
if self.body is None:
840-
if allowFallback:
841-
raise DataNotFoundError('Could not find a valid body using current options.')
854+
if skipBodyNotFound:
855+
fext = None
842856
else:
843-
raise DataNotFoundError('Plain text body could not be found.')
857+
if allowFallback:
858+
raise DataNotFoundError('Could not find a valid body using current options.')
859+
else:
860+
raise DataNotFoundError('Plain text body could not be found.')
844861

845862

846863
if not skipAttachments:
@@ -849,7 +866,7 @@ def save(self, **kwargs):
849866
# Remove skipped attachments.
850867
attachmentNames = [x for x in attachmentNames if x]
851868

852-
if not attachOnly:
869+
if not attachOnly and fext:
853870
with _open(str(path / ('message.' + fext)), mode) as f:
854871
if _json:
855872
emailObj = json.loads(self.getJson())

extract_msg/message_signed_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .exceptions import StandardViolationError
99
from .message_base import MessageBase
1010
from .signed_attachment import SignedAttachment
11-
from .utils import inputToBytes, inputToString, unwrapMultipart
11+
from .utils import inputToString, unwrapMultipart
1212

1313

1414
logger = logging.getLogger(__name__)

0 commit comments

Comments
 (0)