]> git.notmuchmail.org Git - notmuch/blob - bindings/python/notmuch/globals.py
python: replace hardcoding of SONAME version
[notmuch] / bindings / python / notmuch / globals.py
1 """
2 This file is part of notmuch.
3
4 Notmuch is free software: you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by the
6 Free Software Foundation, either version 3 of the License, or (at your
7 option) any later version.
8
9 Notmuch is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with notmuch.  If not, see <http://www.gnu.org/licenses/>.
16
17 Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de>
18 """
19
20 from ctypes import CDLL, Structure, POINTER
21 from version import SOVERSION
22
23 #-----------------------------------------------------------------------------
24 #package-global instance of the notmuch library
25 try:
26     from os import uname
27     if uname()[0] == 'Darwin':
28         nmlib = CDLL("libnotmuch.{0:s}.dylib".format(SOVERSION))
29     else:
30         nmlib = CDLL("libnotmuch.so.{0:s}".format(SOVERSION))
31 except:
32     raise ImportError("Could not find shared 'notmuch' library.")
33
34 from .compat import Python3StringMixIn, encode_utf8 as _str
35
36 class Enum(object):
37     """Provides ENUMS as "code=Enum(['a','b','c'])" where code.a=0 etc..."""
38     def __init__(self, names):
39         for number, name in enumerate(names):
40             setattr(self, name, number)
41
42
43 class NotmuchDatabaseS(Structure):
44     pass
45 NotmuchDatabaseP = POINTER(NotmuchDatabaseS)
46
47
48 class NotmuchQueryS(Structure):
49     pass
50 NotmuchQueryP = POINTER(NotmuchQueryS)
51
52
53 class NotmuchThreadsS(Structure):
54     pass
55 NotmuchThreadsP = POINTER(NotmuchThreadsS)
56
57
58 class NotmuchThreadS(Structure):
59     pass
60 NotmuchThreadP = POINTER(NotmuchThreadS)
61
62
63 class NotmuchMessagesS(Structure):
64     pass
65 NotmuchMessagesP = POINTER(NotmuchMessagesS)
66
67
68 class NotmuchMessageS(Structure):
69     pass
70 NotmuchMessageP = POINTER(NotmuchMessageS)
71
72
73 class NotmuchTagsS(Structure):
74     pass
75 NotmuchTagsP = POINTER(NotmuchTagsS)
76
77
78 class NotmuchDirectoryS(Structure):
79     pass
80 NotmuchDirectoryP = POINTER(NotmuchDirectoryS)
81
82
83 class NotmuchFilenamesS(Structure):
84     pass
85 NotmuchFilenamesP = POINTER(NotmuchFilenamesS)