Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3fca291

Browse files
author
Piers Lauder
committed
Add IMAP4 QUOTA extension methods
1 parent f0a70f6 commit 3fca291

2 files changed

Lines changed: 58 additions & 3 deletions

File tree

Doc/lib/libimaplib.tex

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ \subsection{IMAP4 Objects \label{imap4-objects}}
174174
The method is non-standard, but is supported by the \samp{Cyrus} server.
175175
\end{methoddesc}
176176

177+
\begin{methoddesc}{getquota}{root}
178+
Get the \samp{quota} \var{root}'s resource usage and limits.
179+
This method is part of the IMAP4 QUOTA extension defined in rfc2087.
180+
\end{methoddesc}
181+
182+
\begin{methoddesc}{getquotaroot}{mailbox}
183+
Get the list of \samp{quota} \samp{roots} for the named \var{mailbox}.
184+
This method is part of the IMAP4 QUOTA extension defined in rfc2087.
185+
\end{methoddesc}
186+
177187
\begin{methoddesc}{list}{\optional{directory\optional{, pattern}}}
178188
List mailbox names in \var{directory} matching
179189
\var{pattern}. \var{directory} defaults to the top-level mail
@@ -204,7 +214,7 @@ \subsection{IMAP4 Objects \label{imap4-objects}}
204214
\begin{methoddesc}{open}{host, port}
205215
Opens socket to \var{port} at \var{host}.
206216
The connection objects established by this method
207-
will be used in the \code{read}, \code{readline}, and \code{shutdown} methods.
217+
will be used in the \code{read}, \code{readline}, \code{send}, and \code{shutdown} methods.
208218
You may override this method.
209219
\end{methoddesc}
210220

@@ -263,11 +273,21 @@ \subsection{IMAP4 Objects \label{imap4-objects}}
263273
to the mailbox are not allowed.
264274
\end{methoddesc}
265275

276+
\begin{methoddesc}{send}{data}
277+
Sends \code{data} to the remote server.
278+
You may override this method.
279+
\end{methoddesc}
280+
266281
\begin{methoddesc}{setacl}{mailbox, who, what}
267282
Set an \samp{ACL} for \var{mailbox}.
268283
The method is non-standard, but is supported by the \samp{Cyrus} server.
269284
\end{methoddesc}
270285

286+
\begin{methoddesc}{setquota}{root, limits}
287+
Set the \samp{quota} \var{root}'s resource \var{limits}.
288+
This method is part of the IMAP4 QUOTA extension defined in rfc2087.
289+
\end{methoddesc}
290+
271291
\begin{methoddesc}{shutdown}{}
272292
Close connection established in \code{open}.
273293
You may override this method.

Lib/imaplib.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
# String method conversion by ESR, February 2001.
1717
# GET/SETACL contributed by Anthony Baxter <[email protected]> April 2001.
1818
# IMAP4_SSL contributed by Tino Lange <[email protected]> March 2002.
19+
# GET/SETQUOTA contributed by Andreas Zeidler <[email protected]> June 2002.
1920

20-
__version__ = "2.51"
21+
__version__ = "2.52"
2122

2223
import binascii, re, socket, time, random, sys
2324

@@ -48,6 +49,8 @@
4849
'EXPUNGE': ('SELECTED',),
4950
'FETCH': ('SELECTED',),
5051
'GETACL': ('AUTH', 'SELECTED'),
52+
'GETQUOTA': ('AUTH', 'SELECTED'),
53+
'GETQUOTAROOT': ('AUTH', 'SELECTED'),
5154
'LIST': ('AUTH', 'SELECTED'),
5255
'LOGIN': ('NONAUTH',),
5356
'LOGOUT': ('NONAUTH', 'AUTH', 'SELECTED', 'LOGOUT'),
@@ -59,6 +62,7 @@
5962
'SEARCH': ('SELECTED',),
6063
'SELECT': ('AUTH', 'SELECTED'),
6164
'SETACL': ('AUTH', 'SELECTED'),
65+
'SETQUOTA': ('AUTH', 'SELECTED'),
6266
'SORT': ('SELECTED',),
6367
'STATUS': ('AUTH', 'SELECTED'),
6468
'STORE': ('SELECTED',),
@@ -416,6 +420,28 @@ def getacl(self, mailbox):
416420
return self._untagged_response(typ, dat, 'ACL')
417421

418422

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+
419445
def list(self, directory='""', pattern='*'):
420446
"""List mailbox names in directory matching pattern.
421447
@@ -566,6 +592,15 @@ def setacl(self, mailbox, who, what):
566592
return self._simple_command('SETACL', mailbox, who, what)
567593

568594

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+
569604
def sort(self, sort_criteria, charset, *search_criteria):
570605
"""IMAP4rev1 extension SORT command.
571606
@@ -1186,7 +1221,7 @@ def Time2Internaldate(date_time):
11861221
tt = time.localtime(date_time)
11871222
elif isinstance(date_time, (tuple, time.struct_time)):
11881223
tt = date_time
1189-
elif isinstance(date_time, str):
1224+
elif isinstance(date_time, str) and (date_time[0],date_time[-1]) == ('"','"'):
11901225
return date_time # Assume in correct format
11911226
else:
11921227
raise ValueError("date_time not of a known type")

0 commit comments

Comments
 (0)