imh

Check-in [bc6ff21fd1]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Decode "q code" encoded email headers
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:bc6ff21fd152b39770c7ec69f23b973984af4580b66d81b011ac7f9c3b89aad4
User & Date: ajv-899-334-8894@vsta.org 2016-11-13 01:27:53
Context
2016-11-17
16:52
When we have new messages, switch to our inbox check-in: 2292653bdf user: ajv-899-334-8894@vsta.org tags: master, trunk
2016-11-13
01:27
Decode "q code" encoded email headers check-in: bc6ff21fd1 user: ajv-899-334-8894@vsta.org tags: master, trunk
00:50
Gracefully handle failed SMTP send check-in: d1a5dd1a0c user: ajv-899-334-8894@vsta.org tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to imh.py.

3
4
5
6
7
8
9

10
11
12
13
14
15
16
...
391
392
393
394
395
396
397








398
399
400
401
402
403
404
405
#       Shared routines for doing mh-ish CLI on an imap server
#
import pdb
import imaplib, json, os, sys, getopt, time, base64, html2text
import quopri, textwrap
from rfc822 import AddressList
import chore


# Turn an imap BODYSTRUCTURE into a Python list representation
class BodyParser(object):
    def __init__(self, s):
        self.s = s
        self.peeked = None

................................................................................
        fields = self.collect_fields(fields)
        for f in fields:
            if not f:
                continue
            if ": " not in f:
                continue
            idx = f.index(": ")








            res[f[:idx]] = f[idx+2:]
        return res

    # Convert imap message flags to set
    def flags_set(self, flags):
        if "FLAGS (" not in flags:
            return ()








>







 







>
>
>
>
>
>
>
>
|







3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
...
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
#       Shared routines for doing mh-ish CLI on an imap server
#
import pdb
import imaplib, json, os, sys, getopt, time, base64, html2text
import quopri, textwrap
from rfc822 import AddressList
import chore
from email.header import decode_header

# Turn an imap BODYSTRUCTURE into a Python list representation
class BodyParser(object):
    def __init__(self, s):
        self.s = s
        self.peeked = None

................................................................................
        fields = self.collect_fields(fields)
        for f in fields:
            if not f:
                continue
            if ": " not in f:
                continue
            idx = f.index(": ")
            v = f[idx+2:]

            # For encoded (typically "q code") headers
            dv = decode_header(v)
            if not dv:
                dv = v
            else:
                dv = dv[0][0]
            res[f[:idx]] = dv
        return res

    # Convert imap message flags to set
    def flags_set(self, flags):
        if "FLAGS (" not in flags:
            return ()