Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

NOWPRINT. NOWPRINT. Clemclone, back to the shadows again. -- The Firesign Theater


devel / comp.lang.python / email.message_from_file & quoted printable

SubjectAuthor
o email.message_from_file & quoted printableSkip Montanaro

1
email.message_from_file & quoted printable

<mailman.17.1640292952.3079.python-list@python.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: skip.mon...@gmail.com (Skip Montanaro)
Newsgroups: comp.lang.python
Subject: email.message_from_file & quoted printable
Date: Thu, 23 Dec 2021 14:50:36 -0600
Lines: 81
Message-ID: <mailman.17.1640292952.3079.python-list@python.org>
References: <CANc-5UyPuqb3vN5czu5RE=wb1jm=voah6yg89U1qkWfGOHHJVQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de w8CbLrWeQs9TV8Mf+iZXoguDeLUoNohHpZyFshazBzPQ==
Return-Path: <skip.montanaro@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=Y5RyNcaj;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: UNSURE 0.216
X-Spam-Level: **
X-Spam-Evidence: '*H*': 0.57; '*S*': 0.00; 'bunch': 0.05;
'&gt;&gt;&gt;': 0.07; 'archives': 0.09; 'received:209.85.219':
0.09; 'rendering': 0.09; 'archived': 0.16; 'encoding.': 0.16;
'mon': 0.16; 'stays.': 0.16; 'things,': 0.16; 'think.': 0.16;
'it?': 0.19; 'to:addr:python-list': 0.20; 'maybe': 0.22; 'sat,':
0.22; 'skip:& 40': 0.22; 'section': 0.25; 'seems': 0.26; 'jun':
0.26; 'old': 0.27; '>>>': 0.28; 'example,': 0.28; 'dec': 0.31;
'to:name:python': 0.32; 'message-id:@mail.gmail.com': 0.32; 'but':
0.32; "i'm": 0.33; 'there': 0.33; 'package': 0.34;
'received:google.com': 0.34; 'definitely': 0.35;
'from:addr:gmail.com': 0.35; 'files': 0.36; 'using': 0.37; "it's":
0.37; 'received:209.85': 0.37; 'could': 0.38; 'read': 0.38;
'received:209': 0.39; 'otherwise': 0.39; 'date:': 0.39; 'use':
0.39; '(with': 0.39; 'still': 0.40; 'processed': 0.40; 'above':
0.62; 'from:': 0.62; 'to:': 0.62; 'techniques': 0.62; 'email':
0.63; 'skip:m 20': 0.63; 'hear': 0.64; 'skip:t 40': 0.64; 'parts':
0.65; 'body': 0.67; 'skip:t 30': 0.67; 'skip:e 20': 0.67;
'fixing': 0.69; 'transfer': 0.69; 'above,': 0.70; 'front': 0.70;
'content': 0.72; '1.0': 0.76; 'cheers': 0.76; 'decode': 0.84;
'dent': 0.84; 'inherited': 0.84; 'retains': 0.84; 'stewart': 0.84;
'subject:skip:e 20': 0.84; 'text/html': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:from:date:message-id:subject:to;
bh=Mbs+c5Bq6o6OvJGRa8ksaLXapZlcprzSWJwAVpvGndY=;
b=Y5RyNcajCnFxAZq5+eSzBqtIarD4YWXGFFZpaWreAsvTCWa+MOPEe0GCAw9uRJ2j0l
bSCMwbgMQtX2go41BAbS1AaYDXk2WkIf97q8v9n/dpVM3zJCdgGz4n1MpFYQtyj/2DxD
iOSNesf5Mxa6lIBW43zWg/6Yn1q1d6i5SRjzBqKLEltpl9rRJkRVaTTl44f0bpJMj1yW
w5cIRmE4nRMc/EUgB9GjNIl9ClOuBUsn2dJrbM8MyXa4NraKiW7iTgLUuQrQbUOmhxZo
X28Nk8A+TozwNh6wKWaUBLRRU7A6CslzQBXepheVU6ywlsU2oshP0PJOWJnDWSd1Q63O
f+Bg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
bh=Mbs+c5Bq6o6OvJGRa8ksaLXapZlcprzSWJwAVpvGndY=;
b=KPz6w2RTG+Vx6c3IhJ6L4vZGfRhJnHcbfvpsjKpWWDetJ4lsNZr/efDGSUnU43X+Gi
Lg7MdvevdaBpGrK7FoLWFOJn96VWy81LwBMUSndlD6V0MW75gGaKpiG9CpWw0AKYPpwq
GkiJEW9b+zZMGDkwnlMOkWV+ObwXjET5KiEDKGGwaRXh0bLqv5CffcqkgBQcTC/whHbH
ny+/a99tx2YklmbAmScZlLtdWl1wJnYuDw3eviHDWmGjmSwTDzdvUH7t1CnXwO3/OriC
qcK5MVA6X/zICNzeew4aucxA0oK57ZUU6Y6oOiAMj0XR0KBz2liFLgwPL5jfpcXKUkNZ
lk4g==
X-Gm-Message-State: AOAM532tM7Bb5AS82bn4r+Y0oIkevKg3zxN+sBzvTF6Iv2aCt6/clstb
LZE0Qw5pgWHgAog+zg/DYnfcEbNlV182EuJGRppBQRMMP17YQjw=
X-Google-Smtp-Source: ABdhPJwUub/4Ff/KSu6pqLV1CDShqcD7Ba62Y2ucPfcD+6ghc8MxMJ7n6DupjwGt/i0eHPCmkt1flxO1UqQH8kKbrEo=
X-Received: by 2002:a25:a1e2:: with SMTP id a89mr5574270ybi.761.1640292662307;
Thu, 23 Dec 2021 12:51:02 -0800 (PST)
X-Mailman-Approved-At: Thu, 23 Dec 2021 15:55:50 -0500
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CANc-5UyPuqb3vN5czu5RE=wb1jm=voah6yg89U1qkWfGOHHJVQ@mail.gmail.com>
 by: Skip Montanaro - Thu, 23 Dec 2021 20:50 UTC

I have a bunch of old email archives I'm messing around with, for example,
rendering them on-demand in HTML. Some of the files use quoted printable
content transfer encoding. Here's one (with a number of headers elided):

>From classicrendezvous-admin Mon Dec 4 15:29:22 2000
Message-ID: <027801bfcdaa$fa175230$268cbcd4@stewart>
Reply-To: "Stewart Barrie" <sbarrie@bellefield.worldonline.co.uk>
From: "Stewart Barrie" <sbarrie@bellefield.worldonline.co.uk>
To: <Classicrendezvous@bikelist.org>
Date: Sat, 3 Jun 2000 23:28:00 +0100
MIME-Version: 1.0
X-StripMime: Non-text section removed by stripmime
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;charset="iso-8859-1"
Subject: {ClassicRend]Frame dent

Just inherited a nice 531 Claud Butler from the 60's I think. No =
eylelets and pencil stays. Unfortunately there is nice dent in the =
middle of the seat tube just above front mech clip height. Otherwise it = seems
fine.=20

Any thoughts on restoration? Are there any techniques for fixing dents =
in situ (I can hear the screams already) or are we definitely looking at =
a new seat tube? In which case, is it worth it?

Cheers

Stewart

--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---

This message is stored in a file. I read it using email.message_from_file.
In the example above, the payload still retains the quoted printable bits.
Maybe it's not correctly encoded (no "=20" at the end of the second
paragraph, for example), but I would have thought the email package would
do what it could to decode things, but nope:

>>> print(msg.get_payload())
Just inherited a nice 531 Claud Butler from the 60's I think. No =
eylelets and pencil stays. Unfortunately there is nice dent in the =
middle of the seat tube just above front mech clip height. Otherwise it =
seems fine.=20

Any thoughts on restoration? Are there any techniques for fixing dents =
in situ (I can hear the screams already) or are we definitely looking at =
a new seat tube? In which case, is it worth it?

Cheers

Stewart

--- StripMime Report -- processed MIME parts ---
multipart/alternative

text/plain (text body -- kept)
text/html
---

Am I expecting too much from the email package when munching on crufty
20+yo archived email messages?

Thx,

Skip

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor