Skip to content

Commit e664887

Browse files
Update for version 0.44.0
1 parent 02b8e22 commit e664887

File tree

6 files changed

+37
-25
lines changed

6 files changed

+37
-25
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
**v0.44.0**
2+
* Fixed a bug that caused `MessageBase.headerInit` to always return `False` after the 0.42.0 update.
3+
* Changed `MessageBase.headerInit` to a property.
4+
* Fixed `extract_msg.utils.__all__`.
5+
* Minor regoanization within `extract_msg/utils.py`.
6+
* Minor changes to docstrings.
7+
* Minor README updates.
8+
19
**v0.43.0**
210
* [[TeamMsgExtractor #56](https://github.com/TeamMsgExtractor/msg-extractor/issues/56)] [[TeamMsgExtractor #248](https://github.com/TeamMsgExtractor/msg-extractor/issues/248)] Added new function `MessageBase.asEmailMessage` which will convert the `MessageBase` instance, if possible, to an `email.message.EmailMessage` object. If an embedded MSG file on a `MessageBase` object is of a class that does not have this function, it will simply be attached to the instance as bytes.
311
* Changed imports in `message_base.py` to help with type checkers.

README.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
|License: GPL v3| |PyPI3| |PyPI2|
1+
|License: GPL v3| |PyPI3| |PyPI2| |Read the Docs|
22

33
extract-msg
44
=============
@@ -9,7 +9,7 @@ The python package extract_msg automates the extraction of key email
99
data (from, to, cc, date, subject, body) and the email's attachments.
1010

1111
Documentation can be found in the code, on the `wiki`_, and on the
12-
`read the docs`_ page.
12+
`Read the Docs`_ page.
1313

1414
NOTICE
1515
======
@@ -242,11 +242,16 @@ your access to the newest major version of extract-msg.
242242
.. |License: GPL v3| image:: https://img.shields.io/badge/License-GPLv3-blue.svg
243243
:target: LICENSE.txt
244244

245-
.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.43.0-blue.svg
246-
:target: https://pypi.org/project/extract-msg/0.43.0/
245+
.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.44.0-blue.svg
246+
:target: https://pypi.org/project/extract-msg/0.44.0/
247247

248248
.. |PyPI2| image:: https://img.shields.io/badge/python-3.8+-brightgreen.svg
249249
:target: https://www.python.org/downloads/release/python-3816/
250+
251+
.. |Read the Docs| image:: https://readthedocs.org/projects/msg-extractor/badge/?version=latest
252+
:target: https://msg-extractor.readthedocs.io/en/stable/?badge=latest
253+
:alt: Documentation Status
254+
250255
.. _Matthew Walker: https://github.com/mattgwwalker
251256
.. _Destiny Peterson (The Elemental of Destruction): https://github.com/TheElementalOfDestruction
252257
.. _JP Bourget: https://github.com/punkrokk
@@ -261,5 +266,5 @@ your access to the newest major version of extract-msg.
261266
.. _Patreon: https://www.patreon.com/DestructionE
262267
.. _msg-explorer: https://pypi.org/project/msg-explorer/
263268
.. _wiki: https://github.com/TeamMsgExtractor/msg-extractor/wiki
264-
.. _read the docs: https://msg-extractor.rtfd.io/
269+
.. _Read the Docs: https://msg-extractor.rtfd.io/
265270
.. _Changelog: https://github.com/TeamMsgExtractor/msg-extractor/blob/master/CHANGELOG.md

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
sys.path.insert(0, os.path.abspath(".."))
1313

1414
__author__ = 'Destiny Peterson & Matthew Walker'
15-
__version__ = '0.43.0'
15+
__version__ = '0.44.0'
1616
__year__ = '2023'
1717

1818

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__ = '2023-08-02'
31-
__version__ = '0.43.0'
30+
__date__ = '2023-08-03'
31+
__version__ = '0.44.0'
3232

3333
__all__ = [
3434
# Modules:

extract_msg/msg_classes/calendar_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def _genRecipient(self, recipientType, recipientInt : MeetingRecipientType) -> O
3535
recipientInt = MeetingRecipientType(recipientInt)
3636
value = None
3737
# Check header first.
38-
if self.headerInit():
38+
if self.headerInit:
3939
value = self.header[recipientType]
4040
if value:
4141
value = value.replace(',', self.recipientSeparator)
@@ -44,7 +44,7 @@ def _genRecipient(self, recipientType, recipientInt : MeetingRecipientType) -> O
4444
# it manually.
4545
if not value:
4646
# Check if the header has initialized.
47-
if self.headerInit():
47+
if self.headerInit:
4848
logger.info(f'Header found, but "{recipientType}" is not included. Will be generated from other streams.')
4949

5050
# Get a list of the recipients of the specified type.

extract_msg/msg_classes/message_base.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def __init__(self, path, **kwargs):
8989
# The rest needs to be in a try-except block to ensure the file closes
9090
# if an error occurs.
9191
try:
92+
self.__headerInit = False
9293
self.__recipientSeparator = kwargs.get('recipientSeparator', ';')
9394
self.__deencap = kwargs.get('deencapsulationFunc')
9495
# Initialize properties in the order that is least likely to cause bugs.
@@ -125,7 +126,7 @@ def _genRecipient(self, recipientType, recipientInt : RecipientType) -> Optional
125126
recipientInt = RecipientType(recipientInt)
126127
value = None
127128
# Check header first.
128-
if self.headerInit():
129+
if self.headerInit:
129130
value = self.header[recipientType]
130131
if value:
131132
value = decodeRfc2047(value)
@@ -135,7 +136,7 @@ def _genRecipient(self, recipientType, recipientInt : RecipientType) -> Optional
135136
# it manually.
136137
if not value:
137138
# Check if the header has initialized.
138-
if self.headerInit():
139+
if self.headerInit:
139140
logger.info(f'Header found, but "{recipientType}" is not included. Will be generated from other streams.')
140141

141142
# Get a list of the recipients of the specified type.
@@ -472,16 +473,6 @@ def getSaveRtfBody(self, **_) -> bytes:
472473
# Inject the header into the data.
473474
return self.injectRtfHeader()
474475

475-
def headerInit(self) -> bool:
476-
"""
477-
Checks whether the header has been initialized.
478-
"""
479-
try:
480-
self._header
481-
return True
482-
except AttributeError:
483-
return False
484-
485476
def injectHtmlHeader(self, prepared : bool = False) -> bytes:
486477
"""
487478
Returns the HTML body from the MSG file (will check that it has one) with
@@ -1080,6 +1071,7 @@ def header(self) -> email.message.Message:
10801071
# TODO find authentication results outside of header
10811072
header.add_header('Authentication-Results', None)
10821073

1074+
self.__headerInit = True
10831075
return header
10841076

10851077
@property
@@ -1139,6 +1131,13 @@ def headerFormatProperties(self) -> constants.HEADER_FORMAT_TYPE:
11391131
},
11401132
}
11411133

1134+
@property
1135+
def headerInit(self) -> bool:
1136+
"""
1137+
Checks whether the header has been initialized.
1138+
"""
1139+
return self.__headerInit
1140+
11421141
@functools.cached_property
11431142
def headerText(self) -> Optional[str]:
11441143
"""
@@ -1240,12 +1239,12 @@ def isSent(self) -> bool:
12401239
@functools.cached_property
12411240
def messageId(self) -> Optional[str]:
12421241
headerResult = None
1243-
if self.headerInit():
1242+
if self.headerInit:
12441243
headerResult = self.header['message-id']
12451244
if headerResult is not None:
12461245
return headerResult
12471246

1248-
if self.headerInit():
1247+
if self.headerInit:
12491248
logger.info('Header found, but "Message-Id" is not included. Will be generated from other streams.')
12501249
return self._getStringStream('__substg1.0_1035')
12511250

@@ -1323,7 +1322,7 @@ def sender(self) -> Optional[str]:
13231322
Returns the message sender, if it exists.
13241323
"""
13251324
# Check header first
1326-
if self.headerInit():
1325+
if self.headerInit:
13271326
headerResult = self.header['from']
13281327
if headerResult is not None:
13291328
return decodeRfc2047(headerResult)

0 commit comments

Comments
 (0)