Skip to content

Commit

Permalink
Merge pull request #121 from Syncurity/next-release
Browse files Browse the repository at this point in the history
Next release
  • Loading branch information
TheElementalOfDestruction authored May 19, 2020
2 parents 6fd92d7 + 4f17431 commit 1323b9c
Show file tree
Hide file tree
Showing 12 changed files with 623 additions and 655 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
**v0.23.4**
* [[mattgwwalker #112](https://github.com/mattgwwalker/msg-extractor/issues/112)] Changed method used to get the message from an exception to make it compatible with Python 2 and 3
* [[Syncurity #51](https://github.com/Syncurity/msg-extractor/issues/51)] General cleanup and all around improvements of the code.
**v0.23.3**
* Fixed issues in readme.
* [[Syncurity #50](https://github.com/Syncurity/msg-extractor/issues/50)] Updated `dev_classes.Message` to better match the current `Message` class.
* Fixed bad links in changelog.
* [[mattgwwalker #95](https://github.com/mattgwwalker/msg-extractor/issues/95)] Added falback encoding as well as manual encoding change to `dev_classes.Message`.
* [[mattgwwalker #95](https://github.com/mattgwwalker/msg-extractor/issues/95)] Added fallback encoding as well as manual encoding change to `dev_classes.Message`.

**v0.23.1**
* Fixed issue with embedded msg files caused by the changes in v0.23.0.
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ Joel Kaufman - First implementations of the json and filename flags
.. |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.23.3-blue.svg
:target: https://pypi.org/project/extract-msg/0.23.3/
.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.23.4-blue.svg
:target: https://pypi.org/project/extract-msg/0.23.4/

.. |PyPI1| image:: https://img.shields.io/badge/python-2.7+-brightgreen.svg
:target: https://www.python.org/downloads/release/python-2715/
Expand Down
4 changes: 2 additions & 2 deletions extract_msg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

__author__ = 'Matthew Walker & The Elemental of Creation'
__date__ = '2019-04-20'
__version__ = '0.23.3'
__date__ = '2020-04-27'
__version__ = '0.23.4'

from extract_msg import constants
from extract_msg.attachment import Attachment
Expand Down
41 changes: 25 additions & 16 deletions extract_msg/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ def __init__(self, msg, dir_):
self.__dir = dir_
self.__props = Properties(self._getStream('__properties_version1.0'),
constants.TYPE_ATTACHMENT)
# Get long filename
self.__longFilename = self._getStringStream('__substg1.0_3707')

# Get short filename
self.__shortFilename = self._getStringStream('__substg1.0_3704')

# Get Content-ID
self.__cid = self._getStringStream('__substg1.0_3712')

# Get attachment data
if self.Exists('__substg1.0_37010102'):
Expand Down Expand Up @@ -67,6 +59,23 @@ def _getStringStream(self, filename):
"""
return self.__msg._getStringStream([self.__dir, filename])

def _ensureSet(self, variable, streamID, stingstream = True):
"""
Ensures that the variable exists, otherwise will set it using the specified stream.
After that, return said variable.
If the specified stream is not a string stream, make sure to set :param string stream: to False.
"""
try:
return getattr(self, variable)
except AttributeError:
if stringStream:
value = self._getStringStream(streamID)
else:
value = self._getStream(streamID)
setattr(self, variable, value)
return value

def Exists(self, filename):
"""
Checks if stream exists inside the attachment folder.
Expand All @@ -88,13 +97,13 @@ def save(self, contentId=False, json=False, useFileName=False, raw=False, custom
# If not...
# Check if user wants to save the file under the Content-id
if contentId:
filename = self.__cid
filename = self.cid
# If filename is None at this point, use long filename as first preference
if filename is None:
filename = self.__longFilename
filename = self.longFilename
# Otherwise use the short filename
if filename is None:
filename = self.__shortFilename
filename = self.shortFilename
# Otherwise just make something up!
if filename is None:
filename = 'UnknownFilename ' + \
Expand Down Expand Up @@ -124,9 +133,9 @@ def saveEmbededMessage(self, contentId=False, json=False, useFileName=False, raw
@property
def cid(self):
"""
Returns the content ID of the attachment, if it exists.
Returns the Content ID of the attachment, if it exists.
"""
return self.__cid
return self._ensureSet('_cid', '__substg1.0_3712')

contend_id = cid

Expand All @@ -149,7 +158,7 @@ def longFilename(self):
"""
Returns the long file name of the attachment, if it exists.
"""
return self.__longFilename
return self._ensureSet('_longFilename', '__substg1.0_3707')

@property
def msg(self):
Expand All @@ -170,11 +179,11 @@ def shortFilename(self):
"""
Returns the short file name of the attachment, if it exists.
"""
return self.__shortFilename
return self._ensureSet('_shortFilename', '__substg1.0_3704')

@property
def type(self):
"""
Returns the type of the data.
Returns the (internally used) type of the data.
"""
return self.__type
13 changes: 6 additions & 7 deletions extract_msg/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,6 @@

# END CONSTANTS

def int_to_recipient_type(integer):
"""
Returns the name of the recipient type constant that has the value of :param integer:
"""
return RECIPIENT_DICT[integer]


def int_to_data_type(integer):
"""
Returns the name of the data type constant that has the value of :param integer:
Expand All @@ -378,3 +371,9 @@ def int_to_intelligence(integer):
Returns the name of the intelligence level constant that has the value of :param integer:
"""
return INTELLIGENCE_DICT[integer]

def int_to_recipient_type(integer):
"""
Returns the name of the recipient type constant that has the value of :param integer:
"""
return RECIPIENT_DICT[integer]
Loading

0 comments on commit 1323b9c

Please sign in to comment.