imh

Check-in [b3c9234fa2]
Login

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

Overview
Comment:Support "last" (and "first") so we can do "show 7-last"
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:b3c9234fa2fec7e7a9a4d30a1526fa9458541e9ead24183d6d20eb3ec74d7a53
User & Date: ajv-899-334-8894@vsta.org 2016-12-04 22:37:42
Context
2016-12-05
22:40
Accomodate "pick -subj FOO" without blowing up on trying to parse -subj as message range. check-in: 3a255d5281 user: ajv-899-334-8894@vsta.org tags: master, trunk
2016-12-04
22:37
Support "last" (and "first") so we can do "show 7-last" check-in: b3c9234fa2 user: ajv-899-334-8894@vsta.org tags: master, trunk
22:29
Fail more gracefully on message fetch failure check-in: e590b3c97b user: ajv-899-334-8894@vsta.org tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to imh.py.

333
334
335
336
337
338
339









340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
...
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
    def select_msg(self, mn):
        self.cur_msg = mn
        self.bodstruct = None

    # Parse range out of args, return it as an ordered list.
    # Update args to hold whatever's left (non-message number
    #  stuff, so "pick 1-50 -from joe" works)









    def parse_range(self):
        res = set()
        while True:
            if not self.args:
                break
            a = self.args[0]
            if not a[0].isdigit():
                break

            # low-high
            if '-' in a:
                tup = a.split('-')
                if len(tup) != 2:
                    raise Exception, "Bad message range %s" % (a,)
                l = int(tup[0])
                h = int(tup[1])
                res.update(xrange(l,h+1))

            else:
                # Just a message number
                res.add(int(a))

            # We've consumed this
            del self.args[0]

        return sorted(res)

    # Parse mail file style fields, where continuations
................................................................................
    # and if no message list, current message
    def arg_msgs(self):
        st = self.state

        # Folder, message list
        fn = self.parse_folder()
        fmsgs = self.select_folder(fn)
        msgs = self.parse_range()
        if not msgs:
            if fn in st["curmsgs"]:
                msgs = (st["curmsgs"][fn],)
        if not msgs:
            raise Exception, "No current message"

        return msgs







>
>
>
>
>
>
>
>
>
|





<
<






|
|




|







 







|







333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354


355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
...
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
    def select_msg(self, mn):
        self.cur_msg = mn
        self.bodstruct = None

    # Parse range out of args, return it as an ordered list.
    # Update args to hold whatever's left (non-message number
    #  stuff, so "pick 1-50 -from joe" works)
    def _parse_one(self, arg, fmsgs):
        if arg.isdigit():
            return int(arg)
        if arg == "first":
            return 1
        if arg == "last":
            return fmsgs
        raise Exception, "Unknown message number: %r\n" % (arg,)

    def parse_range(self, fmsgs):
        res = set()
        while True:
            if not self.args:
                break
            a = self.args[0]



            # low-high
            if '-' in a:
                tup = a.split('-')
                if len(tup) != 2:
                    raise Exception, "Bad message range %s" % (a,)
                l = self._parse_one(tup[0], fmsgs)
                h = self._parse_one(tup[1], fmsgs)
                res.update(xrange(l,h+1))

            else:
                # Just a message number
                res.add(self._parse_one(a, fmsgs))

            # We've consumed this
            del self.args[0]

        return sorted(res)

    # Parse mail file style fields, where continuations
................................................................................
    # and if no message list, current message
    def arg_msgs(self):
        st = self.state

        # Folder, message list
        fn = self.parse_folder()
        fmsgs = self.select_folder(fn)
        msgs = self.parse_range(fmsgs)
        if not msgs:
            if fn in st["curmsgs"]:
                msgs = (st["curmsgs"][fn],)
        if not msgs:
            raise Exception, "No current message"

        return msgs

Changes to pick.py.

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
    def run(self):
        st = self.state
        cfg = self.cfg

        # Folder, optional message list
        fn = self.parse_folder()
        fmsgs = self.select_folder(fn)
        msgs = self.parse_range()

        # Arguments to search
        args = []

        # If they specify message numbers, that's a UID sequence
        #  set.
        if msgs:







|







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
    def run(self):
        st = self.state
        cfg = self.cfg

        # Folder, optional message list
        fn = self.parse_folder()
        fmsgs = self.select_folder(fn)
        msgs = self.parse_range(fmsgs)

        # Arguments to search
        args = []

        # If they specify message numbers, that's a UID sequence
        #  set.
        if msgs:

Changes to repl.py.

77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
    def run(self):
        st = self.state
        cfg = self.cfg

        # Folder, message list
        fn = self.parse_folder()
        fmsgs = self.select_folder(fn)
        msgs = self.parse_range()
        if not msgs:
            if fn in st["curmsgs"]:
                msgs = (st["curmsgs"][fn],)
        if not msgs:
            sys.stderr.write("No current message\n")
            return
        if len(msgs) > 1:







|







77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
    def run(self):
        st = self.state
        cfg = self.cfg

        # Folder, message list
        fn = self.parse_folder()
        fmsgs = self.select_folder(fn)
        msgs = self.parse_range(fmsgs)
        if not msgs:
            if fn in st["curmsgs"]:
                msgs = (st["curmsgs"][fn],)
        if not msgs:
            sys.stderr.write("No current message\n")
            return
        if len(msgs) > 1:

Changes to scan.py.

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

        # First a folder to scan, go to it
        # No folder, use current one
        fn = self.parse_folder()
        fmsgs = self.select_folder(fn, readonly=True)

        # Then message list
        msgs = self.parse_range()
        if not msgs:
            # All of them, if not specified
            msgs = range(1, fmsgs+1)

        return msgs

    def run(self):







|







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

        # First a folder to scan, go to it
        # No folder, use current one
        fn = self.parse_folder()
        fmsgs = self.select_folder(fn, readonly=True)

        # Then message list
        msgs = self.parse_range(fmsgs)
        if not msgs:
            # All of them, if not specified
            msgs = range(1, fmsgs+1)

        return msgs

    def run(self):