Skip to content

Commit 0df2e22

Browse files
authored
Merge pull request #16 from openzim/reader
2 parents 53d0c8f + 469ca75 commit 0df2e22

File tree

7 files changed

+600
-19
lines changed

7 files changed

+600
-19
lines changed

libzim/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,3 @@
1616
#
1717
# You should have received a copy of the GNU General Public License
1818
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19-
20-
21-
from libzim_wrapper import Blob
22-
23-
__all__ = ["Blob"]

libzim/libzim_wrapper.pxd

Lines changed: 80 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,16 @@ from cpython.ref cimport PyObject
2121

2222
from libc.stdint cimport uint32_t, uint64_t
2323
from libcpp cimport bool
24-
from libcpp.memory cimport shared_ptr
24+
from libcpp.memory cimport shared_ptr, unique_ptr
2525
from libcpp.string cimport string
2626
from libcpp.vector cimport vector
2727

2828

29+
cdef extern from "zim/zim.h" namespace "zim":
30+
ctypedef uint64_t size_type
31+
ctypedef uint64_t offset_type
32+
33+
2934
cdef extern from "zim/blob.h" namespace "zim":
3035
cdef cppclass Blob:
3136
Blob() except +
@@ -34,19 +39,20 @@ cdef extern from "zim/blob.h" namespace "zim":
3439
const char* end() except +
3540
uint64_t size() except +
3641

42+
3743
cdef extern from "zim/writer/url.h" namespace "zim::writer":
3844
cdef cppclass Url:
3945
string getLongUrl() except +
4046

4147

4248
cdef extern from "zim/writer/article.h" namespace "zim::writer":
43-
cdef cppclass Article:
44-
const string getTitle() except +
45-
49+
cdef cppclass WriterArticle:
50+
pass
4651

4752
cdef extern from "lib.h":
48-
cdef cppclass ZimArticleWrapper(Article):
53+
cdef cppclass ZimArticleWrapper(WriterArticle):
4954
ZimArticleWrapper(PyObject *obj) except +
55+
const string getTitle() except +
5056
const Url getUrl() except +
5157
const string getTitle() except +
5258
const bool isRedirect() except +
@@ -64,3 +70,72 @@ cdef extern from "lib.h":
6470
void finalize() nogil except +
6571
Url getMainUrl() except +
6672
void setMainUrl(string) except +
73+
74+
75+
cdef extern from "zim/article.h" namespace "zim":
76+
cdef cppclass Article:
77+
Article() except +
78+
79+
string getTitle() except +
80+
string getUrl() except +
81+
string getLongUrl() except +
82+
string getMimeType() except +
83+
char getNamespace() except +
84+
bint good() except +
85+
86+
const Blob getData(size_type offset) except +
87+
88+
bint isRedirect() except +
89+
bint isLinktarget() except +
90+
bint isDeleted() except +
91+
92+
Article getRedirectArticle() except +
93+
94+
95+
cdef extern from "zim/fileheader.h" namespace "zim":
96+
cdef cppclass Fileheader:
97+
bint hasMainPage() except +
98+
size_type getMainPage() except +
99+
100+
101+
cdef extern from "zim/search_iterator.h" namespace "zim":
102+
cdef cppclass search_iterator:
103+
search_iterator()
104+
search_iterator operator++()
105+
bint operator==(search_iterator)
106+
bint operator!=(search_iterator)
107+
string get_url()
108+
string get_title()
109+
110+
111+
cdef extern from "zim/search.h" namespace "zim":
112+
cdef cppclass Search:
113+
Search(const File* zimfile)
114+
Search(vector[const File] zimfiles)
115+
search_iterator begin()
116+
search_iterator end()
117+
int get_matches_estimated()
118+
119+
120+
cdef extern from "zim/file.h" namespace "zim":
121+
cdef cppclass File:
122+
File() except +
123+
File(string filename) except +
124+
125+
Article getArticle(size_type idx) except +
126+
Article getArticle(char ns, string url) except +
127+
Article getArticleByUrl(string url) except +
128+
129+
string getMetadata(string name) except +
130+
131+
Fileheader getFileheader() except +
132+
133+
size_type getCountArticles() except +
134+
size_type getNamespaceCount(char ns) except +
135+
136+
string getNamespaces() except +
137+
string getChecksum() except +
138+
string getFilename() except +
139+
140+
unique_ptr[Search] search(const string query, int start, int end);
141+
unique_ptr[Search] suggestions(const string query, int start, int end);

0 commit comments

Comments
 (0)