summaryrefslogtreecommitdiff
path: root/python/mailutils/folder.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/mailutils/folder.py')
-rw-r--r--python/mailutils/folder.py73
1 files changed, 73 insertions, 0 deletions
diff --git a/python/mailutils/folder.py b/python/mailutils/folder.py
new file mode 100644
index 000000000..af9a12983
--- /dev/null
+++ b/python/mailutils/folder.py
@@ -0,0 +1,73 @@
+# GNU Mailutils -- a suite of utilities for electronic mail
+# Copyright (C) 2009-2024 Free Software Foundation, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General
+# Public License along with this library. If not, see
+# <http://www.gnu.org/licenses/>.
+
+from mailutils.c_api import folder
+from mailutils import stream
+from mailutils import auth
+from mailutils import url
+from mailutils.error import FolderError
+
+class Folder:
+ __owner = False
+
+ def __init__ (self, f):
+ if isinstance (f, folder.FolderType):
+ self.folder = f
+ else:
+ self.folder = folder.FolderType ()
+ self.__owner = True
+ status = folder.create (self.folder, f)
+ if status:
+ raise FolderError (status)
+
+ def __del__ (self):
+ if self.__owner:
+ folder.destroy (self.folder)
+ del self.folder
+
+ def open (self):
+ status = folder.open (self.folder)
+ if status:
+ raise FolderError (status)
+
+ def close (self):
+ status = folder.close (self.folder)
+ if status:
+ raise FolderError (status)
+
+ def get_authority (self):
+ status, authority = folder.get_authority (self.folder)
+ if status:
+ raise FolderError (status)
+ return auth.Authority (authority)
+
+ def set_authority (self, authority):
+ status = folder.set_authority (self.folder, authority.authority)
+ if status:
+ raise FolderError (status)
+
+ def get_url (self):
+ status, u = folder.get_url (self.folder)
+ if status:
+ raise FolderError (status)
+ return url.Url (u)
+
+ def list (self, dirname, pattern, max_depth=0):
+ status, lst = folder.list (self.folder, dirname, pattern, max_depth)
+ if status:
+ raise FolderError (status)
+ return lst

Return to:

Send suggestions and report system problems to the System administrator.