Skip to content

Commit

Permalink
Merge pull request #125 from TheElementalOfCreation/master
Browse files Browse the repository at this point in the history
v0.24.2
  • Loading branch information
TheElementalOfDestruction authored Jun 3, 2020
2 parents 63713c6 + 9645861 commit d831238
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
**v0.24.2**
* Fixed bug that somehow escaped detection that caused certain properties to not work.

**v0.24.0**
* [[mattgwwalker # 107](https://github.com/mattgwwalker/msg-extractor/issues/107)] Rewrote the `Messsage.save` function to fix many errors arising from it and to extend its functionality.
* Added new function `isEmptyString` to check if a string passed to it is `None` or is empty.
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.24.0-blue.svg
:target: https://pypi.org/project/extract-msg/0.24.0/
.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.24.2-blue.svg
:target: https://pypi.org/project/extract-msg/0.24.2/

.. |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__ = '2020-05-26'
__version__ = '0.24.0'
__date__ = '2020-05-29'
__version__ = '0.24.2'

from extract_msg import constants
from extract_msg.attachment import Attachment
Expand Down
2 changes: 1 addition & 1 deletion extract_msg/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
with Message(x[0]) as msg:
# Right here we should still be in the path in currentdir
os.chdir(out)
msg.save(toJson = args.json, useFileName = args.use_filename, ContentId = args.cid) #, html = args.html, rtf = args.html)
msg.save(toJson = args.json, useFileName = args.use_filename, ContentId = args.cid, html = args.html, rtf = args.html)
except Exception as e:
print("Error with file '" + x[0] + "': " +
traceback.format_exc())
Expand Down
11 changes: 6 additions & 5 deletions extract_msg/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def sExists(self, filename):
"""
return self.__msg.sExists([self.__dir, filename])

def save(self, contentId=False, json=False, useFileName=False, raw=False, customPath=None, customFilename=None): #, html, rtf):
def save(self, contentId = False, json = False, useFileName = False, raw = False, customPath = None, customFilename = None,
html = False, rtf = False):
# Check if the user has specified a custom filename
filename = None
if customFilename is not None and customFilename != '':
Expand Down Expand Up @@ -119,16 +120,16 @@ def save(self, contentId=False, json=False, useFileName=False, raw=False, custom
with open(filename, 'wb') as f:
f.write(self.__data)
else:
self.saveEmbededMessage(contentId, json, useFileName, raw, customPath, customFilename) #, html, rtf)
self.saveEmbededMessage(contentId, json, useFileName, raw, customPath, customFilename, html, rtf)
return filename

def saveEmbededMessage(self, contentId=False, json=False, useFileName=False, raw=False, customPath=None,
customFilename=None):
def saveEmbededMessage(self, contentId = False, json = False, useFileName = False, raw = False, customPath = None,
customFilename = None, html = False, rtf = False):
"""
Seperate function from save to allow it to
easily be overridden by a subclass.
"""
self.data.save(json, useFileName, raw, contentId, customPath, customFilename)
self.data.save(json, useFileName, raw, contentId, customPath, customFilename, html, rtf)

@property
def cid(self):
Expand Down
18 changes: 9 additions & 9 deletions extract_msg/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Message(olefile.OleFileIO):
Parser for Microsoft Outlook message files.
"""

def __init__(self, path, prefix='', attachmentClass=Attachment, filename=None):
def __init__(self, path, prefix = '', attachmentClass = Attachment, filename = None):
"""
:param path: path to the msg file in the system or is the raw msg file.
:param prefix: used for extracting embeded msg files
Expand Down Expand Up @@ -136,12 +136,12 @@ def _genRecipient(self, recipientType, recipientInt):
if len(f) > 1:
for x in range(1, len(f)):
st += ', {0}'.format(f[x])
self._cc = st
setattr(self, private, st)
else:
setattr(self, private, None)
return getattr(self, private)

def _getStream(self, filename, prefix=True):
def _getStream(self, filename, prefix = True):
filename = self.fix_path(filename, prefix)
if self.exists(filename):
with self.openstream(filename) as stream:
Expand All @@ -150,7 +150,7 @@ def _getStream(self, filename, prefix=True):
logger.info('Stream "{}" was requested but could not be found. Returning `None`.'.format(filename))
return None

def _getStringStream(self, filename, prefix=True):
def _getStringStream(self, filename, prefix = True):
"""
Gets a string representation of the requested filename.
This should ALWAYS return a string (Unicode in python 2)
Expand Down Expand Up @@ -193,7 +193,7 @@ def sExists(self, inp):
inp = self.fix_path(inp)
return self.exists(inp + '001F') or self.exists(inp + '001E')

def fix_path(self, inp, prefix=True):
def fix_path(self, inp, prefix = True):
"""
Changes paths so that they have the proper
prefix (should :param prefix: be True) and
Expand All @@ -215,7 +215,7 @@ def headerInit(self):
except AttributeError:
return False

def listDir(self, streams=True, storages=False):
def listDir(self, streams = True, storages = False):
"""
Replacement for OleFileIO.listdir that runs at the current prefix directory.
"""
Expand All @@ -238,7 +238,7 @@ def listDir(self, streams=True, storages=False):
out.append(x)
return out

def save(self, toJson=False, useFileName=False, raw=False, ContentId=False, customPath=None, customFilename=None): #, html = False, rtf = False):
def save(self, toJson = False, useFileName = False, raw = False, ContentId = False, customPath = None, customFilename = None, html = False, rtf = False):
"""
Saves the message body and attachments found in the message. Setting toJson
to true will output the message body as JSON-formatted text. The body and
Expand Down Expand Up @@ -299,7 +299,7 @@ def save(self, toJson=False, useFileName=False, raw=False, ContentId=False, cust
attachmentNames = []
# Save the attachments
for attachment in self.attachments:
attachmentNames.append(attachment.save(ContentId, toJson, useFileName, raw))#, html = html, rtf = rtf))
attachmentNames.append(attachment.save(ContentId, toJson, useFileName, raw, html = html, rtf = rtf))

# Save the message body
fext = 'json' if toJson else 'txt'
Expand Down Expand Up @@ -350,7 +350,7 @@ def save(self, toJson=False, useFileName=False, raw=False, ContentId=False, cust
# Return to previous directory
os.chdir(oldDir)

def save_attachments(self, contentId=False, json=False, useFileName=False, raw=False, customPath=None):
def save_attachments(self, contentId = False, json = False, useFileName = False, raw = False, customPath = None):
"""
Saves only attachments in the same folder.
"""
Expand Down

0 comments on commit d831238

Please sign in to comment.