Skip to content

Commit

Permalink
Merge pull request #410 from TeamMsgExtractor/next-release
Browse files Browse the repository at this point in the history
Version 0.48.3
  • Loading branch information
TheElementalOfDestruction authored Mar 20, 2024
2 parents 076cb0a + 9e10c2c commit deec504
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
**v0.48.3**
* [[TeamMsgExtractor #409](https://github.com/TeamMsgExtractor/msg-extractor/issues/409)] Added missing private method to `SignedAttachment`.
* Fixed some missing typing information.

**v0.48.2**
* Fixed bugs with `MessageBase.asEmailMessage()`. Numerous improvements to how it handles the data.

Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,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.48.2-blue.svg
:target: https://pypi.org/project/extract-msg/0.48.2/
.. |PyPI3| image:: https://img.shields.io/badge/pypi-0.48.3-blue.svg
:target: https://pypi.org/project/extract-msg/0.48.3/

.. |PyPI2| image:: https://img.shields.io/badge/python-3.8+-brightgreen.svg
:target: https://www.python.org/downloads/release/python-3810/
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__ = 'Destiny Peterson & Matthew Walker'
__date__ = '2024-03-09'
__version__ = '0.48.2'
__date__ = '2024-03-20'
__version__ = '0.48.3'

__all__ = [
# Modules:
Expand Down
2 changes: 1 addition & 1 deletion extract_msg/attachments/attachment_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def _getTypedStream(self, filename: MSG_PATH, _type = None):
raise ReferenceError('The MSGFile for this Attachment instance has been garbage collected.')
return msg._getTypedStream([self.__dir, msgPathToString(filename)], True, _type)

def _handleFnc(self, _zip, filename, customPath, kwargs) -> pathlib.Path:
def _handleFnc(self, _zip, filename, customPath: pathlib.Path, kwargs) -> pathlib.Path:
"""
"Handle Filename Conflict"
Expand Down
42 changes: 42 additions & 0 deletions extract_msg/attachments/signed_att.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,48 @@ def __init__(self, msg, data: bytes, name: str, mimetype: str, node: email.messa
if self.__data is None:
self.__data = data

def _handleFnc(self, _zip, filename, customPath: pathlib.Path, kwargs) -> pathlib.Path:
"""
"Handle Filename Conflict"
Internal function for use in determining how to modify the saving path
when a file with the same name already exists. This is mainly because
any save function that uses files will need to do this functionality.
:returns: A ``pathlib.Path`` object to where the file should be saved.
"""
fullFilename = customPath / filename

overwriteExisting = kwargs.get('overwriteExisting', False)

if _zip:
# If we are writing to a zip file and are not overwriting.
if not overwriteExisting:
name, ext = os.path.splitext(filename)
nameList = _zip.namelist()
if str(fullFilename).replace('\\', '/') in nameList:
for i in range(2, 100):
testName = customPath / f'{name} ({i}){ext}'
if str(testName).replace('\\', '/') not in nameList:
return testName
else:
# If we couldn't find one that didn't exist.
raise FileExistsError(f'Could not create the specified file because it already exists ("{fullFilename}").')
else:
if not overwriteExisting and fullFilename.exists():
# Try to split the filename into a name and extension.
name, ext = os.path.splitext(filename)
# Try to add a number to it so that we can save without overwriting.
for i in range(2, 100):
testName = customPath / f'{name} ({i}){ext}'
if not testName.exists():
return testName
else:
# If we couldn't find one that didn't exist.
raise FileExistsError(f'Could not create the specified file because it already exists ("{fullFilename}").')

return fullFilename

def save(self, **kwargs) -> constants.SAVE_TYPE:
"""
Saves the attachment data.
Expand Down

0 comments on commit deec504

Please sign in to comment.