From 8e3b780755c29b89edefe4518b0be944676c392e Mon Sep 17 00:00:00 2001 From: TheElementalOfDestruction Date: Mon, 29 Aug 2022 13:54:20 -0700 Subject: [PATCH 1/2] v0.36.2 --- .../ContactPicture.jpg | Bin 0 -> 12498 bytes .../message.txt | Bin 0 -> 1496 bytes CHANGELOG.md | 4 +++ README.rst | 4 +-- extract_msg/__init__.py | 4 +-- extract_msg/__main__.py | 1 + extract_msg/contact.py | 2 +- extract_msg/message_base.py | 31 ++++++++++++++---- extract_msg/utils.py | 3 ++ 9 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 2022-06-20_1617 Team Msg Extractor I/ContactPicture.jpg create mode 100644 2022-06-20_1617 Team Msg Extractor I/message.txt diff --git a/2022-06-20_1617 Team Msg Extractor I/ContactPicture.jpg b/2022-06-20_1617 Team Msg Extractor I/ContactPicture.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5e5887d3e21416af552eeab33422dc784dfce23d GIT binary patch literal 12498 zcmeHtcT`jDvi?Runh;QsDiJ|ZQ9!EFq9P(6LI4F+kk~;H5ETg+5(FvIqWB?-N|Yif zN<=`aM7j+lMIto>lp-ymgg}y=-%c!F@tk|kx$C#?x_{j5+8QBw-)Cmtndh0=;eF!u z0kXgCwA%>?2?+s*pg#bw3$O-+7x6Ft-@?!(vRH(Fi7#F(x>!P7Qc^-(LPBy0Y>A|l zjFg0gw4AgIOjcG-R&vSGWlLq3L9b=`iwN;QDJ&umeNa|PLJIone|Yg;0&?O)WNVPH*R3}) zHZk42#mst#%}(20cE9b}>+0sdZ~uX#$Bv)y_Bna#-1(pj!RV0C$jedDF|k+TlCS@s zawGNTt+b5Htn3Flxep&bD=aF0UQ$|CUQ=6F-_ZE#^_!N~wvX+UPaU1K{(;Y528V`6 zzA~n!XJ(mmtoa4LT|$8HH?w|P_BXraAiEZcKrR*I+atBm&YNkhrTO5JKp%n7h?9yPR_9wPH zb?wRbT>EIAT)?;3=-dL}M_x*(6;i0gBp@Bl?r>5Mb@v>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wD! zMhRCojDK?Zp<|c)8kt|QFC@X|arz4%0|u?2N5)WILXoi&CN zA5@4H(04UDp&H3gAV^PtPar6HDg5M(gwEsl?9GM5OX@W2i5qy72Kys}1U_{BamxPi zGn)jiAhIC<&0>7H>&Gu5aQZmz6COfCfX<1ZAkF>+7OFQ8SSW`C$EXZCMtra;IKe>+ z<{z}5VBwHc_+UE)+5QbIBts%cAhag@0*3$pg*G0HHQ}TERuukAv`|%w_<;V901sc# z5Cby>rG{P0_ri}#dNLQsSb)kE^`Dk2>?#bFRn~_}=v^P6%tH0`-tAkledN}x()kzL zvWqIto*NY3eQMRY?)#FVDX+EWPmYfn=qx}zQ;aY6&$S9VI{f&dp)Ytz=P-DHvjD!% zgH2AJxiv0lgT2c!hES0Updr~p(7bfS%-!C#sK<(I*E)XwiJ6de_V4QgL=Gh{HFA1X fWD*YW=V*!;HR literal 0 HcmV?d00001 diff --git a/2022-06-20_1617 Team Msg Extractor I/message.txt b/2022-06-20_1617 Team Msg Extractor I/message.txt new file mode 100644 index 0000000000000000000000000000000000000000..b3c913257bb6cf9949f57c58aa805bf6c8d741d4 GIT binary patch literal 1496 zcmZux+iu!G5Y4kC|HC}C5&_$3dhtt3OQI4rG-{BlJdW)(UUj`|?XF4q`<^wB07->DG;DDY(UBMORPWa_Nnwc^v&>=XXZW@;JJd_E{YK;^@W{w3J>U z*i5X2GM%t-G!q?L-wN%6c>i|9R#0h-ilZN-U;RiqN5(V`-9ZrKibK$Zt&{1K@{I zk_%*Fdm{W2M}N4I=2)Cw#?c+G#EEq}gixyB^53yT@_C2ou{g~T$I6!N=FP?c=yLfm zSlezwRd{Qr7@?=?RiCrXfL82Bqq2JqtOs%5Ei65%WTrm=%N8O@~Y6mMvX z9je&XT<pO}Id6wu%vLOi%x`dBg+`ws`xDqrak{uq!z=-ghpa zOjgo2eK9UgI|&qUc)OF9IFJ6u zG}k2k2$eUy7SyutS*Z=xQYo04-V+!Hy9csZDFL}q6+NOn>YV5+b8cBzrp4erkLenr zF^4sm8?u6((V!9yY{}FFx}Y_yUN|aQKbM2bYN;y%Qw1MIU^h69X$lHereu$KxNYfy z+cY2^?2vdMJ15%?B?GKN>YX*xZICCJXaoLj#AdKHwh|VNfhL$-CrVk%k{+?WC}V|% Wfw%(8NDa(*%ZvkHg3D$cNB;q@rN6!a literal 0 HcmV?d00001 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d84d0b1..6e6e7ecb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +**v0.36.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`. +* Fixed a bug that caused contacts to save the business phone with two colons instead of 1. + **v0.36.1** * [[TeamMsgExtractor #283](https://github.com/TeamMsgExtractor/msg-extractor/issues/283)] Added file for typing recognition. * Added new option to allow messages with `NotImplementedError` attachments to at least save everything not related to them. From the command line this would be `--skip-not-implemented` or `--skip-ni`. From the save function, this would be the `skipNotImplemented` option. diff --git a/README.rst b/README.rst index 200d83e8..10a213da 100644 --- a/README.rst +++ b/README.rst @@ -226,8 +226,8 @@ your access to the newest major version of extract-msg. .. |License: GPL v3| image:: https://img.shields.io/badge/License-GPLv3-blue.svg :target: LICENSE.txt -.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.36.1-blue.svg - :target: https://pypi.org/project/extract-msg/0.36.1/ +.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.36.2-blue.svg + :target: https://pypi.org/project/extract-msg/0.36.2/ .. |PyPI2| image:: https://img.shields.io/badge/python-3.6+-brightgreen.svg :target: https://www.python.org/downloads/release/python-367/ diff --git a/extract_msg/__init__.py b/extract_msg/__init__.py index 5d75405c..02d83f45 100644 --- a/extract_msg/__init__.py +++ b/extract_msg/__init__.py @@ -27,8 +27,8 @@ # along with this program. If not, see . __author__ = 'Destiny Peterson & Matthew Walker' -__date__ = '2022-07-20' -__version__ = '0.36.1' +__date__ = '2022-08-29' +__version__ = '0.36.2' import logging diff --git a/extract_msg/__main__.py b/extract_msg/__main__.py index bfda71d6..9bffe4e3 100644 --- a/extract_msg/__main__.py +++ b/extract_msg/__main__.py @@ -67,6 +67,7 @@ def main() -> None: 'pdf': args.pdf, 'preparedHtml': args.preparedHtml, 'rtf': args.rtf, + 'skipBodyNotFound': args.skipBodyNotFound, 'skipEmbedded': args.skipEmbedded, 'skipNotImplemented': args.skipNotImplemented, 'useMsgFilename': args.useFilename, diff --git a/extract_msg/contact.py b/extract_msg/contact.py index 0c9a60f5..941ae3ff 100644 --- a/extract_msg/contact.py +++ b/extract_msg/contact.py @@ -714,7 +714,7 @@ def strListToStr(inp : Union[str, List[str]]): 'IM Address': self.instantMessagingAddress, }, '-phone numbers-': { - 'Business:': self.businessTelephoneNumber, + 'Business': self.businessTelephoneNumber, 'Business 2': strListToStr(self.businessTelephone2Number), 'Assistant': self.assistantTelephoneNumber, 'Company Main Phone': self.companyMainTelephoneNumber, diff --git a/extract_msg/message_base.py b/extract_msg/message_base.py index db37dea0..3e963fd0 100644 --- a/extract_msg/message_base.py +++ b/extract_msg/message_base.py @@ -659,6 +659,8 @@ def save(self, **kwargs): :param attachmentsOnly: Turns off saving the body and only saves the attachments when set. :param skipAttachments: Turns off saving attachments. + :param skipBodyNotFound: Suppresses errors if no valid body could be + found, simply skipping the step of saving the body. :param charset: If the html is being prepared, the charset to use for the Content-Type meta tag to insert. This exists to ensure that something parsing the html can properly determine the encoding (as @@ -697,6 +699,9 @@ def save(self, **kwargs): attachOnly = kwargs.get('attachmentsOnly', False) # Track if we are skipping attachments. skipAttachments = kwargs.get('skipAttachments', False) + # Track if we should skip the body if no valid body is found instead of + # raising an exception. + skipBodyNotFound = kwargs.get('skipBodyNotFound', False) if pdf: kwargs['preparedHtml'] = True @@ -810,21 +815,30 @@ def save(self, **kwargs): useHtml = True fext = 'html' elif not allowFallback: - raise DataNotFoundError('Could not find the htmlBody.') + if skipBodyNotFound: + fext = None + else: + raise DataNotFoundError('Could not find the htmlBody.') if pdf: if self.htmlBody: usePdf = True fext = 'pdf' elif not allowFallback: - raise DataNotFoundError('Count not find the htmlBody to convert to pdf.') + if skipBodyNotFound: + fext = None + else: + raise DataNotFoundError('Count not find the htmlBody to convert to pdf.') if rtf or (html and not useHtml) or (pdf and not usePdf): if self.rtfBody: useRtf = True fext = 'rtf' elif not allowFallback: - raise DataNotFoundError('Could not find the rtfBody.') + if skipBodyNotFound: + fext = None + else: + raise DataNotFoundError('Could not find the rtfBody.') else: # This was the last resort before plain text, so fall # back to that. @@ -837,10 +851,13 @@ def save(self, **kwargs): # was found but was empty that is considered valid, so we # specifically check against None. if self.body is None: - if allowFallback: - raise DataNotFoundError('Could not find a valid body using current options.') + if skipBodyNotFound: + fext = None else: - raise DataNotFoundError('Plain text body could not be found.') + if allowFallback: + raise DataNotFoundError('Could not find a valid body using current options.') + else: + raise DataNotFoundError('Plain text body could not be found.') if not skipAttachments: @@ -849,7 +866,7 @@ def save(self, **kwargs): # Remove skipped attachments. attachmentNames = [x for x in attachmentNames if x] - if not attachOnly: + if not attachOnly and fext: with _open(str(path / ('message.' + fext)), mode) as f: if _json: emailObj = json.loads(self.getJson()) diff --git a/extract_msg/utils.py b/extract_msg/utils.py index 4404c798..c4469641 100644 --- a/extract_msg/utils.py +++ b/extract_msg/utils.py @@ -292,6 +292,9 @@ def getCommandArgs(args) -> argparse.Namespace: # --allow-fallback parser.add_argument('--allow-fallback', dest='allowFallback', action='store_true', help='Tells the program to fallback to a different save type if the selected one is not possible.') + # --skip-body-not-found + parser.add_argument('--skip-body-not-found', dest=skipBodyNotFound, action='store_true', + help='Skips saving the body if the body cannot be found, rather than throwing an error.') # --zip parser.add_argument('--zip', dest='zip', help='Path to use for saving to a zip file.') From f3c8eef53d1b4a0ced3128ad48e284e6fde63379 Mon Sep 17 00:00:00 2001 From: TheElementalOfDestruction Date: Mon, 29 Aug 2022 14:03:23 -0700 Subject: [PATCH 2/2] Fix release data (forgot to pull before push and messed some stuff up) --- .github/FUNDING.yml | 2 +- CHANGELOG.md | 7 +++++++ README.rst | 5 +++-- extract_msg/utils.py | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 6ff3ccbd..3f902216 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1 @@ -custom: ['https://www.buymeacoffee.com/DestructionE'] +custom: ['https://www.buymeacoffee.com/DestructionE', 'https://www.patreon.com/DestructionE'] diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d84d0b1..35cbdb04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +**v0.36.3** +* 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`. +* Fixed a bug that caused contacts to save the business phone with two colons instead of 1. + +**v0.36.2** +* [[TeamMsgExtractor #286](https://github.com/TeamMsgExtractor/msg-extractor/issues/286)] Fix missing import. + **v0.36.1** * [[TeamMsgExtractor #283](https://github.com/TeamMsgExtractor/msg-extractor/issues/283)] Added file for typing recognition. * Added new option to allow messages with `NotImplementedError` attachments to at least save everything not related to them. From the command line this would be `--skip-not-implemented` or `--skip-ni`. From the save function, this would be the `skipNotImplemented` option. diff --git a/README.rst b/README.rst index 10a213da..10efd19d 100644 --- a/README.rst +++ b/README.rst @@ -87,6 +87,7 @@ refer to the usage information provided from the program's help dialog: --raw Sets whether the output should be raw. If this is not possible, will error. --rtf Sets whether the output should be RTF. If this is not possible, will error. --allow-fallback Tells the program to fallback to a different save type if the selected one is not possible. + --skip-body-not-found Skips saving the body if the body cannot be found, rather than throwing an error. --zip ZIP Path to use for saving to a zip file. --attachments-only Specify to only save attachments from an msg file. --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. .. |License: GPL v3| image:: https://img.shields.io/badge/License-GPLv3-blue.svg :target: LICENSE.txt -.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.36.2-blue.svg - :target: https://pypi.org/project/extract-msg/0.36.2/ +.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.36.3-blue.svg + :target: https://pypi.org/project/extract-msg/0.36.3/ .. |PyPI2| image:: https://img.shields.io/badge/python-3.6+-brightgreen.svg :target: https://www.python.org/downloads/release/python-367/ diff --git a/extract_msg/utils.py b/extract_msg/utils.py index c4469641..406a67fa 100644 --- a/extract_msg/utils.py +++ b/extract_msg/utils.py @@ -293,7 +293,7 @@ def getCommandArgs(args) -> argparse.Namespace: parser.add_argument('--allow-fallback', dest='allowFallback', action='store_true', help='Tells the program to fallback to a different save type if the selected one is not possible.') # --skip-body-not-found - parser.add_argument('--skip-body-not-found', dest=skipBodyNotFound, action='store_true', + parser.add_argument('--skip-body-not-found', dest='skipBodyNotFound', action='store_true', help='Skips saving the body if the body cannot be found, rather than throwing an error.') # --zip parser.add_argument('--zip', dest='zip',