liblore 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- liblore-0.1.0/LICENSES/GPL-2.0-or-later.txt +266 -0
- liblore-0.1.0/PKG-INFO +378 -0
- liblore-0.1.0/README.md +356 -0
- liblore-0.1.0/pyproject.toml +52 -0
- liblore-0.1.0/setup.cfg +4 -0
- liblore-0.1.0/src/liblore/__init__.py +44 -0
- liblore-0.1.0/src/liblore/node.py +247 -0
- liblore-0.1.0/src/liblore/py.typed +0 -0
- liblore-0.1.0/src/liblore/utils.py +467 -0
- liblore-0.1.0/src/liblore.egg-info/PKG-INFO +378 -0
- liblore-0.1.0/src/liblore.egg-info/SOURCES.txt +17 -0
- liblore-0.1.0/src/liblore.egg-info/dependency_links.txt +1 -0
- liblore-0.1.0/src/liblore.egg-info/requires.txt +1 -0
- liblore-0.1.0/src/liblore.egg-info/top_level.txt +1 -0
- liblore-0.1.0/tests/test_email_utils.py +141 -0
- liblore-0.1.0/tests/test_mbox.py +262 -0
- liblore-0.1.0/tests/test_message.py +63 -0
- liblore-0.1.0/tests/test_node.py +446 -0
- liblore-0.1.0/tests/test_thread.py +62 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
Valid-License-Identifier: GPL-2.0-only
|
|
2
|
+
Valid-License-Identifier: GPL-2.0-or-later
|
|
3
|
+
SPDX-URL: https://spdx.org/licenses/GPL-2.0-only.html
|
|
4
|
+
Usage-Guide:
|
|
5
|
+
To use this license in source code, put one of the following SPDX
|
|
6
|
+
tag/value pairs into a comment according to the placement
|
|
7
|
+
guidelines in the licensing rules documentation.
|
|
8
|
+
For 'GNU General Public License (GPL) version 2 only' use:
|
|
9
|
+
SPDX-License-Identifier: GPL-2.0-only
|
|
10
|
+
For 'GNU General Public License (GPL) version 2 or any later version' use:
|
|
11
|
+
SPDX-License-Identifier: GPL-2.0-or-later
|
|
12
|
+
License-Text:
|
|
13
|
+
|
|
14
|
+
GNU GENERAL PUBLIC LICENSE
|
|
15
|
+
Version 2, June 1991
|
|
16
|
+
|
|
17
|
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
|
18
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
19
|
+
|
|
20
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
21
|
+
of this license document, but changing it is not allowed.
|
|
22
|
+
|
|
23
|
+
Preamble
|
|
24
|
+
|
|
25
|
+
The licenses for most software are designed to take away your freedom to share
|
|
26
|
+
and change it. By contrast, the GNU General Public License is intended to
|
|
27
|
+
guarantee your freedom to share and change free software--to make sure the
|
|
28
|
+
software is free for all its users. This General Public License applies to most
|
|
29
|
+
of the Free Software Foundation's software and to any other program whose
|
|
30
|
+
authors commit to using it. (Some other Free Software Foundation software is
|
|
31
|
+
covered by the GNU Lesser General Public License instead.) You can apply it to
|
|
32
|
+
your programs, too.
|
|
33
|
+
|
|
34
|
+
When we speak of free software, we are referring to freedom, not price. Our
|
|
35
|
+
General Public Licenses are designed to make sure that you have the freedom to
|
|
36
|
+
distribute copies of free software (and charge for this service if you wish),
|
|
37
|
+
that you receive source code or can get it if you want it, that you can change
|
|
38
|
+
the software or use pieces of it in new free programs; and that you know you
|
|
39
|
+
can do these things.
|
|
40
|
+
|
|
41
|
+
To protect your rights, we need to make restrictions that forbid anyone to deny
|
|
42
|
+
you these rights or to ask you to surrender the rights. These restrictions
|
|
43
|
+
translate to certain responsibilities for you if you distribute copies of the
|
|
44
|
+
software, or if you modify it.
|
|
45
|
+
|
|
46
|
+
For example, if you distribute copies of such a program, whether gratis or for
|
|
47
|
+
a fee, you must give the recipients all the rights that you have. You must make
|
|
48
|
+
sure that they, too, receive or can get the source code. And you must show them
|
|
49
|
+
these terms so they know their rights.
|
|
50
|
+
We protect your rights with two steps: (1) copyright the software, and (2)
|
|
51
|
+
offer you this license which gives you legal permission to copy, distribute
|
|
52
|
+
and/or modify the software.
|
|
53
|
+
|
|
54
|
+
Also, for each author's protection and ours, we want to make certain that
|
|
55
|
+
everyone understands that there is no warranty for this free software. If the
|
|
56
|
+
software is modified by someone else and passed on, we want its recipients to
|
|
57
|
+
know that what they have is not the original, so that any problems introduced
|
|
58
|
+
by others will not reflect on the original authors' reputations.
|
|
59
|
+
|
|
60
|
+
Finally, any free program is threatened constantly by software patents. We wish
|
|
61
|
+
to avoid the danger that redistributors of a free program will individually
|
|
62
|
+
obtain patent licenses, in effect making the program proprietary. To prevent
|
|
63
|
+
this, we have made it clear that any patent must be licensed for everyone's
|
|
64
|
+
free use or not licensed at all.
|
|
65
|
+
|
|
66
|
+
The precise terms and conditions for copying, distribution and modification
|
|
67
|
+
follow.
|
|
68
|
+
|
|
69
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
70
|
+
|
|
71
|
+
0. This License applies to any program or other work which contains a notice
|
|
72
|
+
placed by the copyright holder saying it may be distributed under the terms of
|
|
73
|
+
this General Public License. The "Program", below, refers to any such program
|
|
74
|
+
or work, and a "work based on the Program" means either the Program or any
|
|
75
|
+
derivative work under copyright law: that is to say, a work containing the
|
|
76
|
+
Program or a portion of it, either verbatim or with modifications and/or
|
|
77
|
+
translated into another language. (Hereinafter, translation is included without
|
|
78
|
+
limitation in the term "modification".) Each licensee is addressed as "you".
|
|
79
|
+
Activities other than copying, distribution and modification are not covered by
|
|
80
|
+
this License; they are outside its scope. The act of running the Program is not
|
|
81
|
+
restricted, and the output from the Program is covered only if its contents
|
|
82
|
+
constitute a work based on the Program (independent of having been made by
|
|
83
|
+
running the Program). Whether that is true depends on what the Program does.
|
|
84
|
+
|
|
85
|
+
1. You may copy and distribute verbatim copies of the Program's source code as
|
|
86
|
+
you receive it, in any medium, provided that you conspicuously and
|
|
87
|
+
appropriately publish on each copy an appropriate copyright notice and
|
|
88
|
+
disclaimer of warranty; keep intact all the notices that refer to this License
|
|
89
|
+
and to the absence of any warranty; and give any other recipients of the
|
|
90
|
+
Program a copy of this License along with the Program.
|
|
91
|
+
You may charge a fee for the physical act of transferring a copy, and you may
|
|
92
|
+
at your option offer warranty protection in exchange for a fee.
|
|
93
|
+
|
|
94
|
+
2. You may modify your copy or copies of the Program or any portion of it, thus
|
|
95
|
+
forming a work based on the Program, and copy and distribute such modifications
|
|
96
|
+
or work under the terms of Section 1 above, provided that you also meet all of
|
|
97
|
+
these conditions:
|
|
98
|
+
|
|
99
|
+
a) You must cause the modified files to carry prominent notices stating
|
|
100
|
+
that you changed the files and the date of any change.
|
|
101
|
+
|
|
102
|
+
b) You must cause any work that you distribute or publish, that in whole
|
|
103
|
+
or in part contains or is derived from the Program or any part thereof,
|
|
104
|
+
to be licensed as a whole at no charge to all third parties under the
|
|
105
|
+
terms of this License.
|
|
106
|
+
|
|
107
|
+
c) If the modified program normally reads commands interactively when
|
|
108
|
+
run, you must cause it, when started running for such interactive use in
|
|
109
|
+
the most ordinary way, to print or display an announcement including an
|
|
110
|
+
appropriate copyright notice and a notice that there is no warranty (or
|
|
111
|
+
else, saying that you provide a warranty) and that users may redistribute
|
|
112
|
+
the program under these conditions, and telling the user how to view a
|
|
113
|
+
copy of this License. (Exception: if the Program itself is interactive
|
|
114
|
+
but does not normally print such an announcement, your work based on the
|
|
115
|
+
Program is not required to print an announcement.)
|
|
116
|
+
|
|
117
|
+
These requirements apply to the modified work as a whole. If identifiable
|
|
118
|
+
sections of that work are not derived from the Program, and can be reasonably
|
|
119
|
+
considered independent and separate works in themselves, then this License, and
|
|
120
|
+
its terms, do not apply to those sections when you distribute them as separate
|
|
121
|
+
works. But when you distribute the same sections as part of a whole which is a
|
|
122
|
+
work based on the Program, the distribution of the whole must be on the terms
|
|
123
|
+
of this License, whose permissions for other licensees extend to the entire
|
|
124
|
+
whole, and thus to each and every part regardless of who wrote it.
|
|
125
|
+
Thus, it is not the intent of this section to claim rights or contest your
|
|
126
|
+
rights to work written entirely by you; rather, the intent is to exercise the
|
|
127
|
+
right to control the distribution of derivative or collective works based on
|
|
128
|
+
the Program.
|
|
129
|
+
|
|
130
|
+
In addition, mere aggregation of another work not based on the Program with the
|
|
131
|
+
Program (or with a work based on the Program) on a volume of a storage or
|
|
132
|
+
distribution medium does not bring the other work under the scope of this
|
|
133
|
+
License.
|
|
134
|
+
|
|
135
|
+
3. You may copy and distribute the Program (or a work based on it, under
|
|
136
|
+
Section 2) in object code or executable form under the terms of Sections 1 and
|
|
137
|
+
2 above provided that you also do one of the following:
|
|
138
|
+
|
|
139
|
+
a) Accompany it with the complete corresponding machine-readable source
|
|
140
|
+
code, which must be distributed under the terms of Sections 1 and 2 above
|
|
141
|
+
on a medium customarily used for software interchange; or,
|
|
142
|
+
|
|
143
|
+
b) Accompany it with a written offer, valid for at least three years, to
|
|
144
|
+
give any third party, for a charge no more than your cost of physically
|
|
145
|
+
performing source distribution, a complete machine-readable copy of the
|
|
146
|
+
corresponding source code, to be distributed under the terms of Sections
|
|
147
|
+
1 and 2 above on a medium customarily used for software interchange; or,
|
|
148
|
+
|
|
149
|
+
c) Accompany it with the information you received as to the offer to
|
|
150
|
+
distribute corresponding source code. (This alternative is allowed only
|
|
151
|
+
for noncommercial distribution and only if you received the program in
|
|
152
|
+
object code or executable form with such an offer, in accord with
|
|
153
|
+
Subsection b above.)
|
|
154
|
+
|
|
155
|
+
The source code for a work means the preferred form of the work for making
|
|
156
|
+
modifications to it. For an executable work, complete source code means all the
|
|
157
|
+
source code for all modules it contains, plus any associated interface
|
|
158
|
+
definition files, plus the scripts used to control compilation and installation
|
|
159
|
+
of the executable. However, as a special exception, the source code distributed
|
|
160
|
+
need not include anything that is normally distributed (in either source or
|
|
161
|
+
binary form) with the major components (compiler, kernel, and so on) of the
|
|
162
|
+
operating system on which the executable runs, unless that component itself
|
|
163
|
+
accompanies the executable.
|
|
164
|
+
|
|
165
|
+
If distribution of executable or object code is made by offering access to copy
|
|
166
|
+
from a designated place, then offering equivalent access to copy the source
|
|
167
|
+
code from the same place counts as distribution of the source code, even though
|
|
168
|
+
third parties are not compelled to copy the source along with the object code.
|
|
169
|
+
|
|
170
|
+
4. You may not copy, modify, sublicense, or distribute the Program except as
|
|
171
|
+
expressly provided under this License. Any attempt otherwise to copy, modify,
|
|
172
|
+
sublicense or distribute the Program is void, and will automatically terminate
|
|
173
|
+
your rights under this License. However, parties who have received copies, or
|
|
174
|
+
rights, from you under this License will not have their licenses terminated so
|
|
175
|
+
long as such parties remain in full compliance.
|
|
176
|
+
|
|
177
|
+
5. You are not required to accept this License, since you have not signed it.
|
|
178
|
+
However, nothing else grants you permission to modify or distribute the Program
|
|
179
|
+
or its derivative works. These actions are prohibited by law if you do not
|
|
180
|
+
accept this License. Therefore, by modifying or distributing the Program (or
|
|
181
|
+
any work based on the Program), you indicate your acceptance of this License to
|
|
182
|
+
do so, and all its terms and conditions for copying, distributing or modifying
|
|
183
|
+
the Program or works based on it.
|
|
184
|
+
|
|
185
|
+
6. Each time you redistribute the Program (or any work based on the Program),
|
|
186
|
+
the recipient automatically receives a license from the original licensor to
|
|
187
|
+
copy, distribute or modify the Program subject to these terms and conditions.
|
|
188
|
+
You may not impose any further restrictions on the recipients' exercise of the
|
|
189
|
+
rights granted herein. You are not responsible for enforcing compliance by
|
|
190
|
+
third parties to this License.
|
|
191
|
+
|
|
192
|
+
7. If, as a consequence of a court judgment or allegation of patent
|
|
193
|
+
infringement or for any other reason (not limited to patent issues), conditions
|
|
194
|
+
are imposed on you (whether by court order, agreement or otherwise) that
|
|
195
|
+
contradict the conditions of this License, they do not excuse you from the
|
|
196
|
+
conditions of this License. If you cannot distribute so as to satisfy
|
|
197
|
+
simultaneously your obligations under this License and any other pertinent
|
|
198
|
+
obligations, then as a consequence you may not distribute the Program at all.
|
|
199
|
+
|
|
200
|
+
For example, if a patent license would not permit royalty-free redistribution
|
|
201
|
+
of the Program by all those who receive copies directly or indirectly through
|
|
202
|
+
you, then the only way you could satisfy both it and this License would be to
|
|
203
|
+
refrain entirely from distribution of the Program.
|
|
204
|
+
|
|
205
|
+
If any portion of this section is held invalid or unenforceable under any
|
|
206
|
+
particular circumstance, the balance of the section is intended to apply and
|
|
207
|
+
the section as a whole is intended to apply in other circumstances.
|
|
208
|
+
It is not the purpose of this section to induce you to infringe any patents or
|
|
209
|
+
other property right claims or to contest validity of any such claims; this
|
|
210
|
+
section has the sole purpose of protecting the integrity of the free software
|
|
211
|
+
distribution system, which is implemented by public license practices. Many
|
|
212
|
+
people have made generous contributions to the wide range of software
|
|
213
|
+
distributed through that system in reliance on consistent application of that
|
|
214
|
+
system; it is up to the author/donor to decide if he or she is willing to
|
|
215
|
+
distribute software through any other system and a licensee cannot impose that
|
|
216
|
+
choice.
|
|
217
|
+
|
|
218
|
+
This section is intended to make thoroughly clear what is believed to be a
|
|
219
|
+
consequence of the rest of this License.
|
|
220
|
+
|
|
221
|
+
8. If the distribution and/or use of the Program is restricted in certain
|
|
222
|
+
countries either by patents or by copyrighted interfaces, the original
|
|
223
|
+
copyright holder who places the Program under this License may add an explicit
|
|
224
|
+
geographical distribution limitation excluding those countries, so that
|
|
225
|
+
distribution is permitted only in or among countries not thus excluded. In such
|
|
226
|
+
case, this License incorporates the limitation as if written in the body of
|
|
227
|
+
this License.
|
|
228
|
+
|
|
229
|
+
9. The Free Software Foundation may publish revised and/or new versions of the
|
|
230
|
+
General Public License from time to time. Such new versions will be similar in
|
|
231
|
+
spirit to the present version, but may differ in detail to address new problems
|
|
232
|
+
or concerns.
|
|
233
|
+
Each version is given a distinguishing version number. If the Program specifies
|
|
234
|
+
a version number of this License which applies to it and "any later version",
|
|
235
|
+
you have the option of following the terms and conditions either of that
|
|
236
|
+
version or of any later version published by the Free Software Foundation. If
|
|
237
|
+
the Program does not specify a version number of this License, you may choose
|
|
238
|
+
any version ever published by the Free Software Foundation.
|
|
239
|
+
10. If you wish to incorporate parts of the Program into other free programs
|
|
240
|
+
whose distribution conditions are different, write to the author to ask for
|
|
241
|
+
permission. For software which is copyrighted by the Free Software Foundation,
|
|
242
|
+
write to the Free Software Foundation; we sometimes make exceptions for this.
|
|
243
|
+
Our decision will be guided by the two goals of preserving the free status of
|
|
244
|
+
all derivatives of our free software and of promoting the sharing and reuse of
|
|
245
|
+
software generally.
|
|
246
|
+
|
|
247
|
+
NO WARRANTY
|
|
248
|
+
|
|
249
|
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
|
|
250
|
+
THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
|
|
251
|
+
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE
|
|
252
|
+
PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
|
|
253
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
254
|
+
FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
|
255
|
+
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU
|
|
256
|
+
ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
257
|
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
|
|
258
|
+
ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE
|
|
259
|
+
PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
|
260
|
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
|
|
261
|
+
INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
|
|
262
|
+
BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
|
263
|
+
FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER
|
|
264
|
+
OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
265
|
+
|
|
266
|
+
END OF TERMS AND CONDITIONS
|
liblore-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: liblore
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Shared library for public-inbox / lore.kernel.org access
|
|
5
|
+
Author-email: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
|
|
6
|
+
License-Expression: GPL-2.0-or-later
|
|
7
|
+
Project-URL: Homepage, https://git.kernel.org/pub/scm/utils/liblore/liblore.git
|
|
8
|
+
Project-URL: Repository, https://git.kernel.org/pub/scm/utils/liblore/liblore.git
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
+
Classifier: Topic :: Communications :: Email
|
|
15
|
+
Classifier: Topic :: Communications :: Email :: Mailing List Servers
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSES/GPL-2.0-or-later.txt
|
|
20
|
+
Requires-Dist: requests>=2.31
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# liblore
|
|
24
|
+
|
|
25
|
+
A Python library for working with [public-inbox](https://public-inbox.org/)
|
|
26
|
+
servers, particularly [lore.kernel.org](https://lore.kernel.org/). It fetches
|
|
27
|
+
email threads, parses mbox files, and provides utilities for working with
|
|
28
|
+
email messages from mailing list archives.
|
|
29
|
+
|
|
30
|
+
## Requirements
|
|
31
|
+
|
|
32
|
+
- Python 3.11 or newer
|
|
33
|
+
- `requests` >= 2.31
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
Install from PyPI:
|
|
38
|
+
|
|
39
|
+
```shell
|
|
40
|
+
pip install liblore
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Or install from source:
|
|
44
|
+
|
|
45
|
+
```shell
|
|
46
|
+
pip install .
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Quick Start
|
|
50
|
+
|
|
51
|
+
The main entry point is the `LoreNode` class. It connects to a public-inbox
|
|
52
|
+
endpoint and lets you fetch threads, search for messages, and work with raw
|
|
53
|
+
mbox data. Use it as a context manager so the underlying HTTP session is
|
|
54
|
+
cleaned up automatically:
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from liblore import LoreNode
|
|
58
|
+
|
|
59
|
+
with LoreNode("https://lore.kernel.org/all") as node:
|
|
60
|
+
msgs = node.get_thread_by_msgid(
|
|
61
|
+
"20250101-example@kernel.org",
|
|
62
|
+
sort=True,
|
|
63
|
+
)
|
|
64
|
+
for msg in msgs:
|
|
65
|
+
print(msg["Subject"])
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
If you omit the URL, it defaults to `https://lore.kernel.org/all`.
|
|
69
|
+
|
|
70
|
+
## API Reference
|
|
71
|
+
|
|
72
|
+
### LoreNode
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from liblore import LoreNode
|
|
76
|
+
|
|
77
|
+
node = LoreNode(url="https://lore.kernel.org/all")
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### Fetching Threads
|
|
81
|
+
|
|
82
|
+
**`node.get_thread_by_msgid(msgid, *, strict=True, sort=False, since=None)`**
|
|
83
|
+
|
|
84
|
+
Fetch a thread by its message ID. This is the highest-level method and the
|
|
85
|
+
one you will reach for most often.
|
|
86
|
+
|
|
87
|
+
- `strict` (default `True`) -- filter results to only messages that belong
|
|
88
|
+
to the thread rooted at `msgid`. When a query returns messages from
|
|
89
|
+
unrelated threads (common with broad date ranges), strict mode discards
|
|
90
|
+
them.
|
|
91
|
+
- `sort` -- sort the returned messages by their `Received` header timestamp.
|
|
92
|
+
- `since` -- a date string appended as a `d:` filter. This uses
|
|
93
|
+
public-inbox's approxidate syntax, so you can write things like
|
|
94
|
+
`"20240115"`, `"2.weeks.ago"`, or `"last.month"`.
|
|
95
|
+
|
|
96
|
+
Returns a `list[EmailMessage]`. Raises `LookupError` if no messages match.
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
with LoreNode() as node:
|
|
100
|
+
# Fetch a thread, sorted by date, only looking at recent messages
|
|
101
|
+
msgs = node.get_thread_by_msgid(
|
|
102
|
+
"20250101-example@kernel.org",
|
|
103
|
+
strict=True,
|
|
104
|
+
sort=True,
|
|
105
|
+
since="20250101",
|
|
106
|
+
)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**`node.get_thread_by_query(query)`**
|
|
110
|
+
|
|
111
|
+
Run a search query and return a deduplicated `list[EmailMessage]`. The query
|
|
112
|
+
uses public-inbox's
|
|
113
|
+
[Xapian search syntax](https://public-inbox.org/HOWTO#search), which supports
|
|
114
|
+
prefixes like `msgid:`, `s:` (subject), `f:` (from), `d:` (date range), and
|
|
115
|
+
more.
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
with LoreNode() as node:
|
|
119
|
+
# Find all messages from a sender in the last month
|
|
120
|
+
msgs = node.get_thread_by_query("f:alice@example.com d:last.month..")
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### Batch Fetching
|
|
124
|
+
|
|
125
|
+
When you need to fetch multiple threads, the batch methods handle the loop for
|
|
126
|
+
you and add a 100 ms cooldown between requests so you're being a good citizen
|
|
127
|
+
to the server.
|
|
128
|
+
|
|
129
|
+
**`node.batch_get_thread_by_msgid(msgids, *, strict=True, sort=False, since=None)`**
|
|
130
|
+
|
|
131
|
+
Fetch threads for a list of message IDs. Calls `get_thread_by_msgid()` for
|
|
132
|
+
each one with a brief pause between requests. Returns a
|
|
133
|
+
`list[list[EmailMessage]]` in the same order as the input.
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
with LoreNode() as node:
|
|
137
|
+
threads = node.batch_get_thread_by_msgid(
|
|
138
|
+
["msg1@example.com", "msg2@example.com", "msg3@example.com"],
|
|
139
|
+
sort=True,
|
|
140
|
+
since="2.weeks.ago",
|
|
141
|
+
)
|
|
142
|
+
for thread in threads:
|
|
143
|
+
print(f"Thread with {len(thread)} messages")
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**`node.batch_get_thread_by_query(queries)`**
|
|
147
|
+
|
|
148
|
+
Run multiple search queries. Same pattern -- calls `get_thread_by_query()` per
|
|
149
|
+
query with a 100 ms cooldown. Returns a `list[list[EmailMessage]]`.
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
with LoreNode() as node:
|
|
153
|
+
results = node.batch_get_thread_by_query([
|
|
154
|
+
"s:fix f:alice@example.com",
|
|
155
|
+
"s:feature f:bob@example.com",
|
|
156
|
+
])
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
#### Raw Mbox Access
|
|
160
|
+
|
|
161
|
+
These methods return raw mbox bytes rather than parsed messages. They are
|
|
162
|
+
useful when you need the unprocessed data, or when you want to feed the
|
|
163
|
+
output into your own parser.
|
|
164
|
+
|
|
165
|
+
**`node.get_mbox_by_msgid(msgid)`** -- fetch a thread's mbox by message ID.
|
|
166
|
+
|
|
167
|
+
**`node.get_mbox_by_query(query)`** -- run a search query and return the
|
|
168
|
+
matching mbox.
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
with LoreNode() as node:
|
|
172
|
+
raw = node.get_mbox_by_msgid("20250101-example@kernel.org")
|
|
173
|
+
with open("thread.mbox", "wb") as f:
|
|
174
|
+
f.write(raw)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### Single Messages
|
|
178
|
+
|
|
179
|
+
**`node.get_message_by_msgid(msgid)`** -- fetch a single raw message (bytes)
|
|
180
|
+
by its message ID. Useful when you need exactly one message rather than an
|
|
181
|
+
entire thread.
|
|
182
|
+
|
|
183
|
+
#### Session Configuration
|
|
184
|
+
|
|
185
|
+
**`node.set_user_agent(app_name, version, plus=None)`** -- set a custom
|
|
186
|
+
`User-Agent` header. Being a good citizen of public infrastructure means
|
|
187
|
+
identifying your tool:
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
node.set_user_agent("my-tool", "1.0")
|
|
191
|
+
# User-Agent: my-tool/1.0
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**`node.set_requests_session(session)`** -- inject your own
|
|
195
|
+
`requests.Session`. Handy when you need custom timeouts, proxies, or
|
|
196
|
+
authentication. Note that the session's `User-Agent` is not overwritten
|
|
197
|
+
when you provide your own.
|
|
198
|
+
|
|
199
|
+
**`node.validate()`** -- check that the configured URL actually points to a
|
|
200
|
+
public-inbox server. Raises `RemoteError` if it does not.
|
|
201
|
+
|
|
202
|
+
**`node.close()`** -- close the HTTP session. Called automatically when
|
|
203
|
+
using `LoreNode` as a context manager.
|
|
204
|
+
|
|
205
|
+
### How the API Layers Fit Together
|
|
206
|
+
|
|
207
|
+
The methods build on each other in layers, from raw bytes up to filtered,
|
|
208
|
+
sorted thread views:
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
get_mbox_by_msgid / get_mbox_by_query -> raw mbox bytes
|
|
212
|
+
|
|
|
213
|
+
get_thread_by_query -> split + dedupe -> list[EmailMessage]
|
|
214
|
+
|
|
|
215
|
+
get_thread_by_msgid -> strict + sort -> list[EmailMessage]
|
|
216
|
+
|
|
|
217
|
+
batch_get_thread_by_msgid / batch_get_... -> rate-limited loop -> list[list[EmailMessage]]
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
You can tap into whichever layer suits your needs. Need raw bytes for
|
|
221
|
+
archiving? Use the `get_mbox_*` methods. Need parsed messages with
|
|
222
|
+
deduplication? Use `get_thread_by_query`. Want the full convenience of
|
|
223
|
+
strict filtering and date sorting? Use `get_thread_by_msgid`.
|
|
224
|
+
|
|
225
|
+
### Utility Functions
|
|
226
|
+
|
|
227
|
+
The `liblore.utils` module provides lower-level helpers for parsing and
|
|
228
|
+
inspecting email messages.
|
|
229
|
+
|
|
230
|
+
#### Header Handling
|
|
231
|
+
|
|
232
|
+
```python
|
|
233
|
+
from liblore.utils import clean_header, get_clean_msgid
|
|
234
|
+
|
|
235
|
+
# Decode RFC 2047 encoded headers
|
|
236
|
+
decoded = clean_header("=?utf-8?q?Re=3A_Some_Subject?=")
|
|
237
|
+
|
|
238
|
+
# Extract a clean message ID (without angle brackets) from a message
|
|
239
|
+
msgid = get_clean_msgid(msg) # reads Message-Id by default
|
|
240
|
+
msgid = get_clean_msgid(msg, "In-Reply-To") # or any other header
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
#### Parsing Messages
|
|
244
|
+
|
|
245
|
+
```python
|
|
246
|
+
from liblore.utils import parse_message
|
|
247
|
+
|
|
248
|
+
# Parse raw email bytes into an EmailMessage
|
|
249
|
+
msg = parse_message(raw_bytes)
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
#### Extracting Message Content
|
|
253
|
+
|
|
254
|
+
```python
|
|
255
|
+
from liblore.utils import (
|
|
256
|
+
msg_get_subject,
|
|
257
|
+
msg_get_author,
|
|
258
|
+
msg_get_payload,
|
|
259
|
+
msg_get_recipients,
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
# Get the decoded subject line
|
|
263
|
+
subject = msg_get_subject(msg)
|
|
264
|
+
|
|
265
|
+
# Strip [PATCH v3 2/5] and Re: prefixes to get the bare subject
|
|
266
|
+
bare = msg_get_subject(msg, strip_prefixes=True)
|
|
267
|
+
|
|
268
|
+
# Get the author as a (name, email) tuple
|
|
269
|
+
name, addr = msg_get_author(msg)
|
|
270
|
+
|
|
271
|
+
# Get the plain-text body, stripping the signature
|
|
272
|
+
body = msg_get_payload(msg)
|
|
273
|
+
|
|
274
|
+
# Get the body without quoted lines or signature
|
|
275
|
+
body = msg_get_payload(msg, strip_quoted=True, strip_signature=True)
|
|
276
|
+
|
|
277
|
+
# Get all recipient email addresses (To + Cc + From)
|
|
278
|
+
recipients = msg_get_recipients(msg)
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
#### Sorting and Threading
|
|
282
|
+
|
|
283
|
+
```python
|
|
284
|
+
from liblore.utils import sort_msgs_by_received, get_strict_thread
|
|
285
|
+
|
|
286
|
+
# Sort messages by their Received timestamp (falls back to Date)
|
|
287
|
+
sorted_msgs = sort_msgs_by_received(msgs)
|
|
288
|
+
|
|
289
|
+
# Filter a list of messages to only those in a specific thread
|
|
290
|
+
thread = get_strict_thread(msgs, "20250101-example@kernel.org")
|
|
291
|
+
|
|
292
|
+
# Break the thread at msgid, ignoring its parent references
|
|
293
|
+
thread = get_strict_thread(msgs, msgid, noparent=True)
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
#### Mbox Splitting
|
|
297
|
+
|
|
298
|
+
```python
|
|
299
|
+
from liblore.utils import split_mbox, split_and_dedupe
|
|
300
|
+
|
|
301
|
+
# Split mboxrd bytes into a list of EmailMessage objects
|
|
302
|
+
msgs = split_mbox(mbox_bytes)
|
|
303
|
+
|
|
304
|
+
# Split and deduplicate by Message-ID (first occurrence wins)
|
|
305
|
+
msgs = split_and_dedupe(mbox_bytes)
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
#### URL Helpers
|
|
309
|
+
|
|
310
|
+
```python
|
|
311
|
+
from liblore.utils import get_msgid_from_url
|
|
312
|
+
|
|
313
|
+
# Extract a message ID from a lore URL
|
|
314
|
+
msgid = get_msgid_from_url("https://lore.kernel.org/all/20250101-example@kernel.org/")
|
|
315
|
+
# -> "20250101-example@kernel.org"
|
|
316
|
+
|
|
317
|
+
# Also works with bare message IDs
|
|
318
|
+
msgid = get_msgid_from_url("<20250101-example@kernel.org>")
|
|
319
|
+
# -> "20250101-example@kernel.org"
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Exceptions
|
|
323
|
+
|
|
324
|
+
All exceptions inherit from `LibloreError`, so you can catch them broadly or
|
|
325
|
+
handle specific cases:
|
|
326
|
+
|
|
327
|
+
```python
|
|
328
|
+
from liblore import LibloreError, RemoteError, PublicInboxError
|
|
329
|
+
|
|
330
|
+
try:
|
|
331
|
+
msgs = node.get_thread_by_msgid("nonexistent@example.com")
|
|
332
|
+
except RemoteError:
|
|
333
|
+
# HTTP request failed (server error, network issue, etc.)
|
|
334
|
+
...
|
|
335
|
+
except PublicInboxError:
|
|
336
|
+
# Something went wrong with the public-inbox operation
|
|
337
|
+
...
|
|
338
|
+
except LibloreError:
|
|
339
|
+
# Catch-all for any liblore error
|
|
340
|
+
...
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
## Development
|
|
344
|
+
|
|
345
|
+
Install with development dependencies:
|
|
346
|
+
|
|
347
|
+
```shell
|
|
348
|
+
pip install -e ".[dev]"
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
Run the test suite:
|
|
352
|
+
|
|
353
|
+
```shell
|
|
354
|
+
pytest
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
Type checking:
|
|
358
|
+
|
|
359
|
+
```shell
|
|
360
|
+
mypy src/liblore/ --strict
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
Linting:
|
|
364
|
+
|
|
365
|
+
```shell
|
|
366
|
+
ruff check src/liblore/
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
## Bug Reports
|
|
370
|
+
|
|
371
|
+
Send bug reports and patches to [tools@kernel.org](mailto:tools@kernel.org).
|
|
372
|
+
|
|
373
|
+
## Licence
|
|
374
|
+
|
|
375
|
+
GPL-2.0-or-later. See [LICENSES/GPL-2.0-or-later.txt](LICENSES/GPL-2.0-or-later.txt)
|
|
376
|
+
for the full text.
|
|
377
|
+
|
|
378
|
+
Copyright The Linux Foundation.
|