|
16 | 16 | # String method conversion by ESR, February 2001. |
17 | 17 | # GET/SETACL contributed by Anthony Baxter <[email protected]> April 2001. |
18 | 18 | # IMAP4_SSL contributed by Tino Lange <[email protected]> March 2002. |
| 19 | +# GET/SETQUOTA contributed by Andreas Zeidler <[email protected]> June 2002. |
19 | 20 |
|
20 | | -__version__ = "2.51" |
| 21 | +__version__ = "2.52" |
21 | 22 |
|
22 | 23 | import binascii, re, socket, time, random, sys |
23 | 24 |
|
|
48 | 49 | 'EXPUNGE': ('SELECTED',), |
49 | 50 | 'FETCH': ('SELECTED',), |
50 | 51 | 'GETACL': ('AUTH', 'SELECTED'), |
| 52 | + 'GETQUOTA': ('AUTH', 'SELECTED'), |
| 53 | + 'GETQUOTAROOT': ('AUTH', 'SELECTED'), |
51 | 54 | 'LIST': ('AUTH', 'SELECTED'), |
52 | 55 | 'LOGIN': ('NONAUTH',), |
53 | 56 | 'LOGOUT': ('NONAUTH', 'AUTH', 'SELECTED', 'LOGOUT'), |
|
59 | 62 | 'SEARCH': ('SELECTED',), |
60 | 63 | 'SELECT': ('AUTH', 'SELECTED'), |
61 | 64 | 'SETACL': ('AUTH', 'SELECTED'), |
| 65 | + 'SETQUOTA': ('AUTH', 'SELECTED'), |
62 | 66 | 'SORT': ('SELECTED',), |
63 | 67 | 'STATUS': ('AUTH', 'SELECTED'), |
64 | 68 | 'STORE': ('SELECTED',), |
@@ -416,6 +420,28 @@ def getacl(self, mailbox): |
416 | 420 | return self._untagged_response(typ, dat, 'ACL') |
417 | 421 |
|
418 | 422 |
|
| 423 | + def getquota(self, root): |
| 424 | + """Get the quota root's resource usage and limits. |
| 425 | +
|
| 426 | + Part of the IMAP4 QUOTA extension defined in rfc2087. |
| 427 | +
|
| 428 | + (typ, [data]) = <instance>.getquota(root) |
| 429 | + """ |
| 430 | + typ, dat = self._simple_command('GETQUOTA', root) |
| 431 | + return self._untagged_response(typ, dat, 'QUOTA') |
| 432 | + |
| 433 | + |
| 434 | + def getquotaroot(self, mailbox): |
| 435 | + """Get the list of quota roots for the named mailbox. |
| 436 | +
|
| 437 | + (typ, [[QUOTAROOT responses...], [QUOTA responses]]) = <instance>.getquotaroot(mailbox) |
| 438 | + """ |
| 439 | + typ, dat = self._simple_command('GETQUOTA', root) |
| 440 | + typ, quota = self._untagged_response(typ, dat, 'QUOTA') |
| 441 | + typ, quotaroot = self._untagged_response(typ, dat, 'QUOTAROOT') |
| 442 | + return typ, [quotaroot, quota] |
| 443 | + |
| 444 | + |
419 | 445 | def list(self, directory='""', pattern='*'): |
420 | 446 | """List mailbox names in directory matching pattern. |
421 | 447 |
|
@@ -566,6 +592,15 @@ def setacl(self, mailbox, who, what): |
566 | 592 | return self._simple_command('SETACL', mailbox, who, what) |
567 | 593 |
|
568 | 594 |
|
| 595 | + def setquota(self, root, limits): |
| 596 | + """Set the quota root's resource limits. |
| 597 | +
|
| 598 | + (typ, [data]) = <instance>.setquota(root, limits) |
| 599 | + """ |
| 600 | + typ, dat = self._simple_command('SETQUOTA', root, limits) |
| 601 | + return self._untagged_response(typ, dat, 'QUOTA') |
| 602 | + |
| 603 | + |
569 | 604 | def sort(self, sort_criteria, charset, *search_criteria): |
570 | 605 | """IMAP4rev1 extension SORT command. |
571 | 606 |
|
@@ -1186,7 +1221,7 @@ def Time2Internaldate(date_time): |
1186 | 1221 | tt = time.localtime(date_time) |
1187 | 1222 | elif isinstance(date_time, (tuple, time.struct_time)): |
1188 | 1223 | tt = date_time |
1189 | | - elif isinstance(date_time, str): |
| 1224 | + elif isinstance(date_time, str) and (date_time[0],date_time[-1]) == ('"','"'): |
1190 | 1225 | return date_time # Assume in correct format |
1191 | 1226 | else: |
1192 | 1227 | raise ValueError("date_time not of a known type") |
|
0 commit comments