Skip to content

Commit 95acde4

Browse files
committed
Move BaseWritingItem so that it is available in _Creator
1 parent eca9365 commit 95acde4

File tree

1 file changed

+61
-63
lines changed

1 file changed

+61
-63
lines changed

libzim/libzim.pyx

Lines changed: 61 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,67 @@ class Hint(enum.Enum):
254254
FRONT_ARTICLE = zim.HintKeys.FRONT_ARTICLE
255255

256256

257+
class BaseWritingItem:
258+
"""
259+
Data to be added to the archive.
260+
261+
This is a stub to override. Pass a subclass of it to `Creator.add_item()`
262+
"""
263+
__module__ = writer_module_name
264+
265+
def __init__(self):
266+
self._blob = None
267+
get_indexdata = None
268+
269+
def get_path(self) -> str:
270+
"""Full path of item.
271+
272+
The path must be absolute and unique.
273+
274+
Returns:
275+
Path of the item.
276+
"""
277+
raise NotImplementedError("get_path must be implemented.")
278+
279+
def get_title(self) -> str:
280+
"""Item title. Might be indexed and used in suggestions.
281+
282+
Returns:
283+
Title of the item.
284+
"""
285+
raise NotImplementedError("get_title must be implemented.")
286+
287+
def get_mimetype(self) -> str:
288+
"""MIME-type of the item's content.
289+
290+
Returns:
291+
Mimetype of the item.
292+
"""
293+
raise NotImplementedError("get_mimetype must be implemented.")
294+
295+
def get_contentprovider(self) -> ContentProvider:
296+
"""ContentProvider containing the complete content of the item.
297+
298+
Returns:
299+
The content provider of the item.
300+
"""
301+
raise NotImplementedError("get_contentprovider must be implemented.")
302+
303+
def get_hints(self) -> Dict[Hint, pyint]:
304+
"""Get the Hints that help the Creator decide how to handle this item.
305+
306+
Hints affects compression, presence in suggestion, random and search.
307+
308+
Returns:
309+
Hints to help the Creator decide how to handle this item.
310+
"""
311+
raise NotImplementedError("get_hints must be implemented.")
312+
313+
def __repr__(self) -> str:
314+
return (
315+
f"{self.__class__.__name__}(path={self.get_path()}, "
316+
f"title={self.get_title()})"
317+
)
257318

258319
cdef class _Creator:
259320
"""ZIM Creator.
@@ -644,69 +705,6 @@ class IndexData:
644705
return None
645706
646707
647-
class BaseWritingItem:
648-
"""
649-
Data to be added to the archive.
650-
651-
This is a stub to override. Pass a subclass of it to `Creator.add_item()`
652-
"""
653-
__module__ = writer_module_name
654-
655-
def __init__(self):
656-
self._blob = None
657-
get_indexdata = None
658-
659-
def get_path(self) -> str:
660-
"""Full path of item.
661-
662-
The path must be absolute and unique.
663-
664-
Returns:
665-
Path of the item.
666-
"""
667-
raise NotImplementedError("get_path must be implemented.")
668-
669-
def get_title(self) -> str:
670-
"""Item title. Might be indexed and used in suggestions.
671-
672-
Returns:
673-
Title of the item.
674-
"""
675-
raise NotImplementedError("get_title must be implemented.")
676-
677-
def get_mimetype(self) -> str:
678-
"""MIME-type of the item's content.
679-
680-
Returns:
681-
Mimetype of the item.
682-
"""
683-
raise NotImplementedError("get_mimetype must be implemented.")
684-
685-
def get_contentprovider(self) -> ContentProvider:
686-
"""ContentProvider containing the complete content of the item.
687-
688-
Returns:
689-
The content provider of the item.
690-
"""
691-
raise NotImplementedError("get_contentprovider must be implemented.")
692-
693-
def get_hints(self) -> Dict[Hint, pyint]:
694-
"""Get the Hints that help the Creator decide how to handle this item.
695-
696-
Hints affects compression, presence in suggestion, random and search.
697-
698-
Returns:
699-
Hints to help the Creator decide how to handle this item.
700-
"""
701-
raise NotImplementedError("get_hints must be implemented.")
702-
703-
def __repr__(self) -> str:
704-
return (
705-
f"{self.__class__.__name__}(path={self.get_path()}, "
706-
f"title={self.get_title()})"
707-
)
708-
709-
710708
class Creator(_Creator):
711709
"""Creator to create ZIM files."""
712710
__module__ = writer_module_name

0 commit comments

Comments
 (0)