summaryrefslogtreecommitdiffabout
path: root/python/2/mailutils/folder.py
blob: ecd3fc9525b3a48a22bf0a616fdeac02dac9c981 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#  GNU Mailutils -- a suite of utilities for electronic mail
#  Copyright (C) 2009-2019 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_level=0):
        status, lst = folder.list (self.folder, dirname, pattern, max_level)
        if status:
            raise FolderError (status)
        return lst

Return to:

Send suggestions and report system problems to the System administrator.