Skip to content

Commit

Permalink
Updated actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedele Mantuano committed Mar 19, 2024
1 parent 36776c8 commit 09f3ba4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
sudo cpan -f -i Email::Outlook::Message
- name: Run pre-commit
if: matrix.python-version == '3.10'
run: |
make pre-commit
Expand All @@ -44,11 +45,13 @@ jobs:
cat tests/mails/mail_malformed_3 | mail-parser -k -j
- name: Report to Coveralls
if: matrix.python-version == '3.10'
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Build
if: matrix.python-version == '3.10'
run: |
python -m build
Expand Down
6 changes: 2 additions & 4 deletions src/mailparser/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,8 @@ def get_args():
help="Path where store attachments")

parser.add_argument(
'-v',
'--version',
action='version',
version='%(prog)s {}'.format(__version__))
'-v', '--version', action='version', version=f'%(prog)s {__version__}'
)

return parser

Expand Down
13 changes: 4 additions & 9 deletions src/mailparser/mailparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,11 @@ def __init__(self, message=None):
Init a new object from a message object structure.
"""
self._message = message
log.debug(
"All headers of emails: {}".format(", ".join(message.keys())))
log.debug(f'All headers of emails: {", ".join(message.keys())}')
self.parse()

def __str__(self):
if self.message:
return self.subject
else:
return six.text_type()
return self.subject if self.message else six.text_type()

@classmethod
def from_file_obj(cls, fp):
Expand All @@ -159,7 +155,7 @@ def from_file_obj(cls, fp):
try:
fp.seek(0)
except IOError:
# When stdout is a TTY it's a character device
# When stdout is a TTY it's a character device,
# and it's not seekable, you cannot seek in a TTY.
pass
finally:
Expand Down Expand Up @@ -299,8 +295,7 @@ def _make_mail(self, complete=True):

for i in keys:
log.debug("Getting header or part {!r}".format(i))
value = getattr(self, i)
if value:
if value := getattr(self, i):
mail[i] = value

# add defects
Expand Down

0 comments on commit 09f3ba4

Please sign in to comment.