Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

A right is not what someone gives you; it's what no one can take from you. -- Ramsey Clark


devel / comp.lang.python / Why is there no get_body() in mailbox.Maildir?

SubjectAuthor
* Why is there no get_body() in mailbox.Maildir?Chris Green
`* Re: Why is there no get_body() in mailbox.Maildir?Stefan Ram
 `* Re: Why is there no get_body() in mailbox.Maildir?Chris Green
  `- Re: Why is there no get_body() in mailbox.Maildir?Stefan Ram

1
Why is there no get_body() in mailbox.Maildir?

<tpfc7i-n9kc1.ln1@esprimo.zbmc.eu>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16248&group=comp.lang.python#16248

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: cl...@isbd.net (Chris Green)
Newsgroups: comp.lang.python
Subject: Why is there no get_body() in mailbox.Maildir?
Date: Sun, 28 Nov 2021 14:20:13 +0000
Lines: 49
Message-ID: <tpfc7i-n9kc1.ln1@esprimo.zbmc.eu>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net 7JuXraGsJ5YrcvzJqj01LwBw7FgOZ3T7PFpYTiX8++/P+0HgA=
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:o8dq9nOIjj5/1oLTyLScpKHVHao=
User-Agent: tin/2.4.6-20210226 ("Glen Albyn") (Linux/5.13.0-21-generic (x86_64))
 by: Chris Green - Sun, 28 Nov 2021 14:20 UTC

I have the following error:-

chris@esprimo$ ./showmail.py boating/Odin/moorings/angers "01 Oct 2009 18:03:00"
Traceback (most recent call last):
File "/home/chris/dev/cgi-bin/./showmail.py", line 24, in <module>
print(msg.get_body('plain',))
AttributeError: 'MaildirMessage' object has no attribute 'get_body'

It's being returned by the following (rather trivial) Python program:-

#!/usr/bin/python3
#
#
# replacement for complex Zend/PHP E-Mail message extraction
#
import mailbox
import email
import sys
import os

mbroot = "/home/chris/mail/folder"

mbname = os.path.join(mbroot, sys.argv[1])

mb = mailbox.Maildir(mbname)
#
#
# run through the messages in the mailbox looking for date/time match
#
for msg in mb:
# print(msg.get("Subject"))
# print(msg.get("Date"))
if sys.argv[2] in msg.get("Date"):
print(msg.get_body('plain',))
exit(0)
exit(1)

I thought MaildirMessage inherited from email.message, it has inherited the
get() method so why not the get_body() method? I'm running Python 3.9.7
on xubuntu Linux 21.10.

Is there another way of doing this or do I have to sort through the message
parts and stuff? It sounded like get_body() would make things easier.

--
Chris Green
·

Re: Why is there no get_body() in mailbox.Maildir?

<get_body-20211128171128@ram.dialup.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16249&group=comp.lang.python#16249

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Why is there no get_body() in mailbox.Maildir?
Date: 28 Nov 2021 16:12:07 GMT
Organization: Stefan Ram
Lines: 11
Expires: 1 Mar 2022 11:59:58 GMT
Message-ID: <get_body-20211128171128@ram.dialup.fu-berlin.de>
References: <tpfc7i-n9kc1.ln1@esprimo.zbmc.eu>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de Dh5qn78uTVMNC7aBMD02iger+aYnVZcLqA5+6wsJP8rwGS
X-Copyright: (C) Copyright 2021 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Sun, 28 Nov 2021 16:12 UTC

Chris Green <cl@isbd.net> writes:
>I thought MaildirMessage inherited from email.message,

It inherits from mailbox.Message which inherits from
email.message.Message which has no "get_body" method.

email.message.MIMEPart has a get_body method.
Also check out: get_payload.

Re: Why is there no get_body() in mailbox.Maildir?

<rmoc7i-s7jd1.ln1@esprimo.zbmc.eu>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16253&group=comp.lang.python#16253

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: cl...@isbd.net (Chris Green)
Newsgroups: comp.lang.python
Subject: Re: Why is there no get_body() in mailbox.Maildir?
Date: Sun, 28 Nov 2021 16:52:11 +0000
Lines: 24
Message-ID: <rmoc7i-s7jd1.ln1@esprimo.zbmc.eu>
References: <tpfc7i-n9kc1.ln1@esprimo.zbmc.eu> <get_body-20211128171128@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net +RS7OBGwsFNx/2dZnSAE0AFfnPccjgfYpYsurDvQsiNYB1pGA=
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:Ze2jOYJgM/PN1VdIB/wSZjC6t+g=
User-Agent: tin/2.4.6-20210226 ("Glen Albyn") (Linux/5.13.0-21-generic (x86_64))
 by: Chris Green - Sun, 28 Nov 2021 16:52 UTC

Stefan Ram <ram@zedat.fu-berlin.de> wrote:
> Chris Green <cl@isbd.net> writes:
> >I thought MaildirMessage inherited from email.message,
>
> It inherits from mailbox.Message which inherits from
> email.message.Message which has no "get_body" method.
>
So the documentation at:-
https://docs.python.org/3/library/email.message.html

is very confusing then. It has a get_body method listed in the
email.message.EmailMessage class.

Where is email.message.Message documented?

> email.message.MIMEPart has a get_body method.
>
> Also check out: get_payload.
>
>
--
Chris Green
·

Re: Why is there no get_body() in mailbox.Maildir?

<reference-20211128181411@ram.dialup.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16255&group=comp.lang.python#16255

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Why is there no get_body() in mailbox.Maildir?
Date: 28 Nov 2021 17:15:09 GMT
Organization: Stefan Ram
Lines: 21
Expires: 1 Mar 2022 11:59:58 GMT
Message-ID: <reference-20211128181411@ram.dialup.fu-berlin.de>
References: <tpfc7i-n9kc1.ln1@esprimo.zbmc.eu> <get_body-20211128171128@ram.dialup.fu-berlin.de> <rmoc7i-s7jd1.ln1@esprimo.zbmc.eu>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de jXPPrJSp/29uPJ5W1rsADQhU7+MtcEvB83wSgZwuB39Pvx
X-Copyright: (C) Copyright 2021 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Sun, 28 Nov 2021 17:15 UTC

Chris Green <cl@isbd.net> writes:
>Where is email.message.Message documented?

Looking at

The Python Library Reference, Release 3.9.0a3,

I see:

chapter 20 Internet Data Handling

section 20.1 email - An email and MIME handling package

subsection 20.1.9 email.message.Message:
Representing an email message using the compat32 API

. Other versions of the documentation might have
different numbers for this chapter, section, and
subsection.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor