zimscraperlib.zim.providers
libzim Providers accepting a ref arg to keep it away from garbage collection
Use case is to pass it the Item instance that created the Provider so that the Item lives longer than the provider, thus allowing: - to keep a single copy of the data if it is to be indexed (and thus Provider instanced twice) - to release whatever needs to be once we know data won't be fetched anymore
Classes:
-
FileLikeProvider–Provider referrencing a file-like object
-
FileProvider– -
StringProvider– -
URLProvider–Provider downloading content as it is consumed by the libzim
FileLikeProvider
Bases: ContentProvider
Provider referrencing a file-like object
Use this to keep a single-copy of a content in memory. Useful for indexed content
Methods:
Attributes:
Source code in src/zimscraperlib/zim/providers.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
fileobj
instance-attribute
fileobj = fileobj
ref
instance-attribute
ref = ref
size
instance-attribute
size = size
gen_blob
gen_blob() -> Generator[Blob]
Source code in src/zimscraperlib/zim/providers.py
60 61 | |
get_size
get_size() -> int
Source code in src/zimscraperlib/zim/providers.py
57 58 | |
FileProvider
Bases: FileProvider
Attributes:
-
ref–
Source code in src/zimscraperlib/zim/providers.py
20 21 22 23 24 25 26 27 | |
ref
instance-attribute
ref = ref
StringProvider
Bases: StringProvider
Attributes:
-
ref–
Source code in src/zimscraperlib/zim/providers.py
31 32 33 | |
ref
instance-attribute
ref = ref
URLProvider
Bases: ContentProvider
Provider downloading content as it is consumed by the libzim
Useful for non-indexed content for which feed() is called only once
Methods:
-
gen_blob– -
get_size– -
get_size_of–
Attributes:
Source code in src/zimscraperlib/zim/providers.py
69 70 71 72 73 74 75 76 77 78 | |
ref
instance-attribute
ref = ref
resp
instance-attribute
resp = session.get(url, stream=True)
size
instance-attribute
size = size if size is not None else self.get_size_of(url)
url
instance-attribute
url = url
gen_blob
gen_blob() -> Generator[Blob]
Source code in src/zimscraperlib/zim/providers.py
91 92 93 94 95 | |
get_size
get_size() -> int
Source code in src/zimscraperlib/zim/providers.py
88 89 | |
get_size_of
staticmethod
Source code in src/zimscraperlib/zim/providers.py
80 81 82 83 84 85 86 | |