API Documentation
github
A script to download files from GitHub, preserving the original commit dates.
Created on 2023-12-12
@author: wf
Usage:
python github.py
GithubDownloader
Downloader for github files with timestamp preservation.
Source code in thunderbird/github.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
|
__init__(target_dir, urls)
Initializes the GithubDownloader with a target directory and a dictionary mapping URLs to repositories.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_dir |
str
|
The directory where files will be downloaded. |
required |
urls |
List[str]
|
A dictionary of URLs to their corresponding repositories. |
required |
Source code in thunderbird/github.py
104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
download_file(gh_file)
Downloads a file based on the provided download gh_fileuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gh_file(GithubFile) |
the download url, repo,filepath etc |
required |
Source code in thunderbird/github.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|
download_files()
Downloads all files based on the prepared download gh_fileurations.
Source code in thunderbird/github.py
118 119 120 121 |
|
from_args(args)
classmethod
Creates an instance of GithubDownloader from command line arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args |
list
|
A list of command line arguments. |
required |
Returns:
Type | Description |
---|---|
GithubDownloader
|
An instance of GithubDownloader. |
Raises:
Type | Description |
---|---|
ValueError
|
If insufficient arguments are provided. |
Source code in thunderbird/github.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
|
set_file_timestamp(filepath, timestamp)
Sets the file's timestamp.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
str
|
The path to the local file. |
required |
timestamp |
str
|
The timestamp string in ISO format. |
required |
Source code in thunderbird/github.py
145 146 147 148 149 150 151 152 153 154 |
|
GithubFile
dataclass
Data class to hold the details for each github file.
Attributes:
Name | Type | Description |
---|---|---|
url |
str
|
The URL to the file. |
repo |
str
|
The repository name. |
file_path |
str
|
The relative path of the file. |
status_msg |
Optional[str]
|
A status message regarding the download. |
timestamp |
Optional[datetime]
|
The timestamp of the last commit. |
timestamp_iso |
Optional[str]
|
timestamp in iso format |
Source code in thunderbird/github.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
__post_init__()
Post-initialization to parse the URL and construct the raw URL for downloading the file.
Source code in thunderbird/github.py
46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
get_commit_date()
Gets the last commit date of my file from GitHub and sets my timestamp accordingly
Source code in thunderbird/github.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
set_file_timestamp(target_dir)
Sets the file's timestamp based on the commit date.
Source code in thunderbird/github.py
84 85 86 87 88 89 90 |
|
to_json()
Converts the me to JSON.
Source code in thunderbird/github.py
60 61 62 |
|
main()
Main function to run the script.
Source code in thunderbird/github.py
177 178 179 180 181 182 |
|
mail
Created on 2020-10-24
@author: wf
IndexingState
dataclass
State of the index_db for all mailboxes
Source code in thunderbird/mail.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
|
error_rate
property
Calculate the error rate in percent
get_update_lod()
get a list of dict of update records
Source code in thunderbird/mail.py
217 218 219 220 221 222 223 224 225 |
|
show_index_report(verbose=False, with_print=True)
Displays a report on the indexing results of email mailboxes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
indexing_result |
IndexingResult
|
The result of the indexing process containing detailed results. |
required |
verbose |
bool
|
If True, displays detailed error and success messages. |
False
|
with_print(bool) |
if True - actually print out the index report |
required |
Returns: an indexing report message
Source code in thunderbird/mail.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
Mail
Bases: object
a single mail
Source code in thunderbird/mail.py
1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 |
|
__init__(user, mailid, tb=None, debug=False, keySearch=True)
Constructor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user(string) |
userid of the user |
required | |
mailid(string) |
unique id of the mail |
required | |
debug(bool) |
True if debugging should be activated |
required | |
keySearch(bool) |
True if a slow keySearch should be tried when lookup fails |
required |
Source code in thunderbird/mail.py
1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 |
|
asWikiMarkup()
convert me to wiki markup in Wikison notation
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
a http://wiki.bitplan.com/index.php/WikiSon notation |
Source code in thunderbird/mail.py
1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 |
|
as_html()
Generate the HTML representation of the mail.
Source code in thunderbird/mail.py
1566 1567 1568 1569 1570 1571 |
|
as_html_error_msg()
Generates an HTML formatted error message for the Mail instance.
This method should be called when a Mail object is requested but not found.
It uses the normalize_mailid
method to format the mail ID in the error message.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
An HTML string representing the error message. |
Source code in thunderbird/mail.py
1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 |
|
as_html_section(section_name)
convert my content to the given html section
Parameters:
Name | Type | Description | Default |
---|---|---|---|
section_name(str) |
the name of the section to create |
required |
Source code in thunderbird/mail.py
1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 |
|
check_mailid()
check the mailid
Source code in thunderbird/mail.py
1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 |
|
extract_headers()
update the headers
Source code in thunderbird/mail.py
1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 |
|
extract_message(lenient=False)
Extracts the message body and headers from the email message.
This method decodes each part of the email message, handling different content types and charsets. It appends the decoded text to the message object's text and HTML attributes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lenient |
bool
|
If True, the method will not raise an exception for decoding errors, and will instead skip the problematic parts. |
False
|
Source code in thunderbird/mail.py
1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 |
|
fixedPartName(partname, contentType, partIndex)
get a fixed version of the partname
Parameters:
Name | Type | Description | Default |
---|---|---|---|
partname(str) |
the name of the part |
required | |
defaultName(str) |
the default name to use |
required |
Source code in thunderbird/mail.py
1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 |
|
getHeader(headerName)
get the header with the given name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
headerName(str) |
the name of the header |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
the header value |
Source code in thunderbird/mail.py
1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 |
|
get_iso_date(msg)
classmethod
Extracts and formats the date from the email header in ISO format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
Mail
|
The mail object from which to extract the date. |
required |
Returns:
Type | Description |
---|---|
str
|
Tuple[str, Optional[str], Optional[str]]: A tuple containing the msg_date, the formatted date in ISO format, |
Optional[str]
|
and an error message if the date cannot be extracted or parsed, otherwise None. |
Source code in thunderbird/mail.py
1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 |
|
mail_part_row(loop_index, part)
Generate a table row for a mail part.
Source code in thunderbird/mail.py
1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 |
|
normalize_mailid(mail_id)
classmethod
remove the surrounding <> of the given mail_id
Source code in thunderbird/mail.py
1262 1263 1264 1265 1266 1267 1268 |
|
part_as_fileresponse(part_index, attachments_path=None)
Return the specified part of a message as a FileResponse.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
part_index |
int
|
The index of the part to be returned. |
required |
Returns:
Name | Type | Description |
---|---|---|
FileResponse |
Any
|
A FileResponse object representing the specified part. |
Raises:
Type | Description |
---|---|
IndexError
|
If the part_index is out of range of the message parts. |
ValueError
|
If the part content is not decodable. |
Note
The method assumes that self.msgParts is a list-like container holding the message parts. Since FastAPI's FileResponse is designed to work with file paths, this function writes the content to a temporary file.
Source code in thunderbird/mail.py
1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 |
|
search(use_index_db=True)
Search for an email by its ID in the specified Thunderbird mailbox database.
This method allows searching either the gloda database or the index database based on the use_index_db
parameter.
It returns a dictionary representing the found email or None if not found.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
use_index_db |
bool
|
If True, the search will be performed in the index database. If False, the search will be performed in the gloda database (default). |
True
|
Returns:
Type | Description |
---|---|
Optional[Dict[str, Any]]
|
Optional[Dict[str, Any]]: A dictionary representing the found email, or None if not found. |
Source code in thunderbird/mail.py
1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 |
|
table_line(key, value)
Generate a table row with a key and value.
Source code in thunderbird/mail.py
1501 1502 1503 |
|
toSbdFolder(folderURI)
staticmethod
get the SBD folder for the given folderURI as a tuple
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folderURI(str) |
the folder uri |
required |
Returns: sbdFolder(str): the prefix folder(str): the local path
Source code in thunderbird/mail.py
1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 |
|
try_decode(byte_str, charset, lenient)
Attempts to decode a byte string using multiple charsets.
Tries to decode the byte string using a series of common charsets, returning the decoded string upon success. If all attempts fail, it either raises a UnicodeDecodeError or returns None, based on the lenient flag.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
byte_str |
bytes
|
The byte string to be decoded. |
required |
charset |
str
|
The initial charset to attempt decoding with. |
required |
lenient |
bool
|
If True, suppresses UnicodeDecodeError and returns None for undecodable byte strings. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The decoded string, or None if lenient is True and decoding fails. |
Raises:
Type | Description |
---|---|
UnicodeDecodeError
|
If decoding fails and lenient is False. |
Source code in thunderbird/mail.py
1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 |
|
MailArchive
dataclass
Represents a single mail archive for a user.
Attributes:
Name | Type | Description |
---|---|---|
user |
str
|
The user to whom the mail archive belongs. |
gloda_db_path |
str
|
The file path of the mailbox global database (sqlite). |
index_db_path |
str
|
The file path of the mailbox index database (sqlite). |
profile |
str
|
the Thunderbird profile directory of this mailbox. |
gloda_db_update_time |
str
|
The last update time of the global database, default is None. |
index_db_update_time |
str
|
The last update time of the index database, default is None. |
Source code in thunderbird/mail.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
|
__post_init__()
Post-initialization processing to set the database update times.
Source code in thunderbird/mail.py
71 72 73 74 75 76 77 78 79 80 |
|
index_db_exists()
Checks if the index database file exists and is not empty.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the index database file exists and has a size greater than zero, otherwise False. |
Source code in thunderbird/mail.py
58 59 60 61 62 63 64 65 66 67 68 69 |
|
to_dict(index=None)
Converts the mail archive data to a dictionary, including the update times for both databases.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index |
int
|
An optional index to be added to the dictionary. |
None
|
Returns:
Type | Description |
---|---|
Dict[str, str]
|
Dict[str, str]: The dictionary representation of the mail archive. |
Source code in thunderbird/mail.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
|
MailArchives
Manages a collection of MailArchive instances for different users.
Attributes:
Name | Type | Description |
---|---|---|
user_list |
List[str]
|
A list of user names. |
mail_archives |
Dict[str, MailArchive]
|
A dictionary mapping users to their MailArchive instances. |
Source code in thunderbird/mail.py
724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 |
|
__init__(user_list)
Initializes the MailArchives with a list of users.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_list |
List[str]
|
A list of user names. |
required |
Source code in thunderbird/mail.py
733 734 735 736 737 738 739 740 741 |
|
as_view_lod()
Creates a list of dictionaries representation of the mail archives.
Returns:
Type | Description |
---|---|
List[Dict[str, str]]
|
List[Dict[str,str]]: A list of dictionaries, each representing a mail archive. |
Source code in thunderbird/mail.py
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 |
|
MailLookup
dataclass
A data class representing a mail lookup entity.
Attributes:
Name | Type | Description |
---|---|---|
message_index |
int
|
The index of the message. |
folder_path |
str
|
The path to the folder containing the message. |
message_id |
str
|
The unique identifier of the message. |
start_pos |
int
|
The start byte position of the message in the mailbox file. |
stop_pos |
int
|
The stop byte position of the message in the mailbox file. |
Source code in thunderbird/mail.py
1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 |
|
from_gloda_record(mail_record)
classmethod
Creates a MailLookup instance from a Gloda record.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mail_record |
Dict
|
A dictionary representing a Gloda record. |
required |
Returns:
Name | Type | Description |
---|---|---|
MailLookup |
MailLookup
|
An instance of MailLookup. |
Source code in thunderbird/mail.py
1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 |
|
from_index_db_record(mail_record)
classmethod
Creates a MailLookup instance from an index database record.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mail_record |
Dict
|
A dictionary representing an index database record. |
required |
Returns:
Name | Type | Description |
---|---|---|
MailLookup |
MailLookup
|
An instance of MailLookup. |
Source code in thunderbird/mail.py
1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 |
|
from_mail_record(mail_record)
classmethod
Creates a MailLookup instance based on the source of the mail record.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mail_record |
Dict
|
A dictionary containing the mail record. |
required |
Returns:
Name | Type | Description |
---|---|---|
MailLookup |
MailLookup
|
An instance of MailLookup based on the source. |
Source code in thunderbird/mail.py
1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 |
|
Thunderbird
Bases: MailArchive
Thunderbird Mailbox access
Source code in thunderbird/mail.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 |
|
__init__(user, db=None, profile=None)
construct a Thunderbird access instance for the given user
Source code in thunderbird/mail.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
|
add_mailbox(mailbox_path, mailboxes, progress_bar, restore_toc=False)
add a ThunderbirdMailBox for the given mailbox_path to the mailboxes
Source code in thunderbird/mail.py
278 279 280 281 282 283 284 285 286 |
|
do_create_or_update_index(ixs, progress_bar=None, relative_paths=None, callback=None)
Create or update an index of emails from Thunderbird mailboxes, storing the data in an SQLite database. If an index already exists and is up-to-date, this method will update it instead of creating a new one.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ixs |
IndexingState
|
IndexingState: the indexing state to work with |
required |
progress_bar |
Progressbar
|
Progress bar to display the progress of index creation. |
None
|
relative_paths |
Optional[List[str]]
|
List of relative mailbox paths to specifically update. If None, updates all mailboxes or based on |
None
|
Source code in thunderbird/mail.py
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 |
|
getProfileMap()
classmethod
get the profile map from a thunderbird.yaml file
Source code in thunderbird/mail.py
695 696 697 698 699 700 701 702 703 |
|
get_indexing_state(force_create=False)
Check if the index database needs to be updated or created.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force_create |
bool
|
Flag to force creation of a new index. |
False
|
Returns:
Type | Description |
---|---|
IndexingState
|
IndexingState |
Source code in thunderbird/mail.py
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
|
get_mailboxes(progress_bar=None, restore_toc=False)
Create a dict of Thunderbird mailboxes.
Source code in thunderbird/mail.py
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
|
get_mailboxes_by_relative_path()
Retrieves all mailboxes and returns a dictionary keyed by their relative folder paths.
This method fetches all Thunderbird mailboxes and organizes them in a dictionary where the keys are the relative paths of the mailboxes, providing a quick way to access a mailbox by its relative path.
Returns:
Type | Description |
---|---|
Dict[str, ThunderbirdMailbox]
|
Dict[str, ThunderbirdMailbox]: A dictionary where the keys are relative folder paths and the values are ThunderbirdMailbox objects representing the corresponding mailboxes. |
Source code in thunderbird/mail.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
|
get_mailboxes_dod_from_sqldb(sql_db)
Retrieve the mailbox list of dictionaries (LoD) from the given SQL database, and return it as a dictionary keyed by relative_folder_path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sql_db |
SQLDB
|
An instance of SQLDB connected to the SQLite database. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary of mailbox dictionaries, keyed by relative_folder_path. |
Source code in thunderbird/mail.py
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 |
|
get_profiles_path()
classmethod
get the profile path
Source code in thunderbird/mail.py
683 684 685 686 687 688 689 690 691 692 693 |
|
get_synched_mailbox_view_lod()
Fetches and synchronizes mailbox data from the filesystem and SQL database and returns a unified view.
Returns:
Type | Description |
---|---|
List[Dict[str, Any]]: A unified list of dictionaries, each representing a mailbox. |
Source code in thunderbird/mail.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
|
index_mailbox(mailbox, progress_bar, force_create)
Process a single mailbox for updating the index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mailbox |
ThunderbirdMailbox
|
The mailbox to be processed. |
required |
progress_bar |
Progressbar
|
Progress bar object for visual feedback. |
required |
force_create |
bool
|
Flag to force creation of a new index. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
tuple
|
A tuple containing the message count and any exception occurred. |
Source code in thunderbird/mail.py
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 |
|
prepare_mailboxes_for_indexing(ixs, progress_bar=None, relative_paths=None)
Prepare a list of mailboxes for indexing by identifying which ones need to be updated.
This function iterates through all Thunderbird mailboxes, checking if each needs an update based on the last update time in the index database. It returns two dictionaries: one containing all mailboxes and another containing only the mailboxes that need updating.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ixs |
IndexingState
|
IndexingState: the indexing state to work on |
required |
force_create |
bool
|
Flag to force creation of a new index for all mailboxes. |
required |
progress_bar |
Optional[Progressbar]
|
A progress bar instance for displaying the progress. |
None
|
relative_paths |
Optional[List[str]]
|
A list of relative paths for specific mailboxes to update. If None, all mailboxes are considered. |
None
|
Returns:
Type | Description |
---|---|
Tuple[Dict[str, ThunderbirdMailbox], Dict[str, ThunderbirdMailbox]]
|
Tuple[Dict[str, ThunderbirdMailbox], Dict[str, ThunderbirdMailbox]]: A tuple containing two dictionaries. The first dictionary contains all mailboxes, and the second contains only mailboxes that need updating. |
Source code in thunderbird/mail.py
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
|
query(sql_query, params)
query this mailbox gloda
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sql_query(str) |
the sql query to execute |
required | |
params |
the parameters for the query |
required |
Source code in thunderbird/mail.py
712 713 714 715 716 717 718 719 720 721 |
|
to_view_lod(fs_mailboxes_dict, db_mailboxes_dict, force_count=False)
Merges mailbox information from the filesystem and SQL database into a unified view.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fs_mailboxes_dict |
Dict[str, ThunderbirdMailbox]
|
Mailboxes from the filesystem. |
required |
db_mailboxes_dict |
Dict[str, Any]
|
Mailboxes from the SQL database. |
required |
force_count(bool) |
if True get count from mailboxes (costly!) |
required |
Returns: List[Dict[str, Any]]: A unified list of dictionaries, each representing a mailbox.
Source code in thunderbird/mail.py
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
|
ThunderbirdMailbox
mailbox wrapper
Source code in thunderbird/mail.py
776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 |
|
__init__(tb, folder_path, use_relative_path=False, restore_toc=True, debug=False)
Initializes a new Mailbox object associated with a specific Thunderbird email client and mailbox folder.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tb |
Thunderbird
|
An instance of the Thunderbird class representing the email client to which this mailbox belongs. |
required |
folder_path |
str
|
The file system path to the mailbox folder. |
required |
use_relative_path |
bool
|
If True, use a relative path for the mailbox folder. Default is False. |
False
|
restore_toc(bool) |
If True restore the table of contents |
required | |
debug |
bool
|
A flag for enabling debug mode. Default is False. |
False
|
The constructor sets the Thunderbird instance, folder path, and debug flag. It checks if the provided folder_path
is a valid file and raises a ValueError if it does not exist. The method also handles the extraction of
the relative folder path from the provided folder_path, especially handling the case where "Mail/Local Folders"
is part of the path. Finally, it initializes the mailbox using the mailbox.mbox
method.
Raises:
Type | Description |
---|---|
ValueError
|
If the provided folder_path does not correspond to an existing file. |
Source code in thunderbird/mail.py
781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 |
|
as_relative_path(folder_path)
staticmethod
convert the folder_path to a relative path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folder_path(str) |
the folder path to convert |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the relative path |
Source code in thunderbird/mail.py
852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 |
|
as_view_record(index)
return me as dict to view in a list of dicts grid
Source code in thunderbird/mail.py
841 842 843 844 845 846 847 848 849 850 |
|
close()
close the mailbox
Source code in thunderbird/mail.py
1084 1085 1086 1087 1088 |
|
get_index_lod()
get the list of dicts for indexing
Source code in thunderbird/mail.py
980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 |
|
get_message_by_key(messageKey)
Retrieves the email message by its message key.
This method fetches an email message based on its unique message key from the mbox mailbox file. It uses the
messageKey
to index into the mbox file and retrieve the specific message. The method profiles the time taken
to fetch the message using the Profiler
utility class for performance monitoring.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
messageKey |
int
|
The unique key (index) of the email message to be retrieved. |
required |
Returns:
Name | Type | Description |
---|---|---|
Message |
Message
|
The email message object corresponding to the specified message key. |
Note
The messageKey
is assumed to be 1-based when passed to this function, but the mailbox.mbox
class uses
0-based indexing, so 1 is subtracted from messageKey
for internal use.
Source code in thunderbird/mail.py
1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 |
|
get_message_by_pos(start_pos, stop_pos)
Fetches an email message by its start and stop byte positions in the mailbox file and parses it into an email.message.Message object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_pos |
int
|
The starting byte position of the message in the mailbox file. |
required |
stop_pos |
int
|
The stopping byte position of the message in the mailbox file. |
required |
Returns:
Name | Type | Description |
---|---|---|
Message |
Optional[Message]
|
The email message object parsed from the specified byte range, |
Raises: FileNotFoundError: If the mailbox file does not exist. IOError: If an error occurs during file opening or reading. ValueError: If the byte range does not represent a valid email message.
Source code in thunderbird/mail.py
1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 |
|
get_toc_lod_from_sqldb(sql_db)
Retrieve the index list of dictionaries (LoD) representing the TOC from the given SQL database.
This method performs a SQL query to fetch the TOC information, which includes the email index, start position, and stop position for each email in the mailbox corresponding to the current folder path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sql_db |
SQLDB
|
An instance of SQLDB connected to the SQLite database. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
A list of dictionaries, each containing the index and TOC information for an email. |
Source code in thunderbird/mail.py
883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 |
|
restore_toc_from_lod(index_lod)
Restores the table of contents of the mailbox using records from an SQLite database.
This method iterates over a list of dictionaries where each dictionary contains details about an email, including its positions in the mailbox file. It uses this information to reconstruct the mailbox's TOC.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index_lod |
list of dict
|
A list of records from the SQLite database. Each record is a dictionary containing details about an email, including its positions in the mailbox file. |
required |
Source code in thunderbird/mail.py
947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 |
|
restore_toc_from_sqldb(sql_db)
Restore the table of contents from the given SQL database.
This method fetches the TOC data from the SQLite database and uses it to rebuild the TOC in the mailbox.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sql_db |
SQLDB
|
An instance of SQLDB connected to the SQLite database. |
required |
Source code in thunderbird/mail.py
871 872 873 874 875 876 877 878 879 880 881 |
|
search_message_by_key(mailid)
search messages by key
Source code in thunderbird/mail.py
1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 |
|
to_dict()
Converts the ThunderbirdMailbox data to a dictionary for SQL database storage.
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: The dictionary representation of the ThunderbirdMailbox. |
Source code in thunderbird/mail.py
825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 |
|
to_view_lod(index_lod, user)
classmethod
Converts a list of index record dictionaries into a format suitable for display in an ag-grid. It renames and repositions the 'email_index' key, removes 'start_pos' and 'stop_pos', and converts 'message_id' to a hyperlink using a custom Link.create() function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index_lod |
List[Dict[str, Any]]
|
A list of dictionaries representing the index records. |
required |
user |
str
|
The user identifier to be used in constructing URLs for hyperlinks. |
required |
Returns:
Type | Description |
---|---|
List[Dict[str, Any]]
|
List[Dict[str, Any]]: The list of modified index record dictionaries. |
Source code in thunderbird/mail.py
904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 |
|
mail_cmd
Created on 2023-11-23
@author: wf
ThunderbirdMailCmd
Bases: WebserverCmd
command line access to pyThunderbird
Source code in thunderbird/mail_cmd.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
getArgParser(description, version_msg)
override the default argparser call
Source code in thunderbird/mail_cmd.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
handle_args()
Handles command line arguments.
This method processes the command line arguments provided to the script. It checks for the presence of required arguments and initializes the Mail object if the necessary arguments are provided.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the arguments are processed successfully, False otherwise. |
Source code in thunderbird/mail_cmd.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
main(argv=None)
main call
Source code in thunderbird/mail_cmd.py
100 101 102 103 104 105 106 107 108 |
|
profiler
Created on 2021-10-15
@author: wf
Profiler
simple profiler
Source code in thunderbird/profiler.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
__init__(msg, profile=True)
construct me with the given msg and profile active flag
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg(str) |
the message to show if profiling is active |
required | |
profile(bool) |
True if messages should be shown |
required |
Source code in thunderbird/profiler.py
14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
time(extraMsg='')
time the action and print if profile is active
Source code in thunderbird/profiler.py
28 29 30 31 32 33 34 35 |
|
search
Created on 2023-12-06
@author: wf
MailSearch
utility module to search Thunderbird mails https://github.com/WolfgangFahl/pyThunderbird/issues/15
Source code in thunderbird/search.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
__init__(webserver, tb, search_dict, with_ui=True, result_limit=1000)
Constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
webserver |
The webserver instance. |
required | |
tb |
The Thunderbird instance. |
required | |
search_dict |
dict
|
The dictionary containing search parameters. |
required |
result_limit(int) |
maximum number of mails to be displayed |
required | |
with_ui |
bool
|
If True, sets up the UI components. |
True
|
Source code in thunderbird/search.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
construct_query(search_criteria)
Construct the SQL query based on the search criteria.
Args:
search_criteria (dict): The dictionary containing search parameters.
Returns:
tuple: A tuple containing the SQL query string and the list of parameters.
The search is based on the index_db
table structure:
CREATE TABLE mail_index ( folder_path TEXT, message_id TEXT, sender TEXT, recipient TEXT, subject TEXT, date TEXT, iso_date TEXT, email_index INTEGER, start_pos INTEGER, stop_pos INTEGER, error TEXT )
Source code in thunderbird/search.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
on_search(_event)
async
Handle the search based on the search form criteria.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event |
GenericEventArguments
|
Event arguments (unused in this method). |
required |
Source code in thunderbird/search.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
setup_form(search_dict)
Set up a search form.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
search_dict |
dict
|
The dictionary containing search parameters. |
required |
Source code in thunderbird/search.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
tb_webserver
Created on 2023-11-23
@author: wf
ThunderbirdSolution
Bases: InputWebSolution
the Thunderbird Mail solution
Source code in thunderbird/tb_webserver.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
|
__init__(webserver, client)
Initialize the solution
Calls the constructor of the base solution Args: webserver (DynamicCompotenceMapWebServer): The webserver instance associated with this context. client (Client): The client instance this context is associated with.
Source code in thunderbird/tb_webserver.py
172 173 174 175 176 177 178 179 180 181 182 183 |
|
create_or_update_index(user, profile_key)
async
user interface to start create or updating index
Source code in thunderbird/tb_webserver.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
|
home()
async
provide the main content page
Source code in thunderbird/tb_webserver.py
459 460 461 462 463 464 |
|
on_select_folder(folder_path)
async
open the folder
Source code in thunderbird/tb_webserver.py
350 351 352 353 354 355 356 |
|
run_indexing(tb, progress_bar)
prepare and run indexing of mailboxes
Source code in thunderbird/tb_webserver.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
|
setup_content()
select users
Source code in thunderbird/tb_webserver.py
452 453 454 455 456 457 |
|
showMail(user, mailid)
async
Show the given mail of the given user.
Source code in thunderbird/tb_webserver.py
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 |
|
show_folder(user, folder_path)
async
show the folder with the given path
Source code in thunderbird/tb_webserver.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
|
show_folders(user, profile_key)
async
Asynchronously shows a user's folder contents based on a profile key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user |
str
|
Username for identifying the user profile. |
required |
profile_key |
str
|
Thunderbird profile key |
required |
Returns:
Name | Type | Description |
---|---|---|
None |
None
|
The function is intended for display purposes only. |
Source code in thunderbird/tb_webserver.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
|
show_mailboxes(user, profile_key)
async
Shows a mailboxes for a Thunderbird user profile
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user |
str
|
Username for identifying the user profile. |
required |
profile_key |
str
|
Thunderbird profile key. |
required |
Source code in thunderbird/tb_webserver.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
show_search(user, profile_key)
async
Shows a search interface for Thunderbird mails.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user |
str
|
Username for identifying the user profile. |
required |
profile_key |
str
|
Thunderbird profile key. |
required |
Source code in thunderbird/tb_webserver.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
|
ThunderbirdWebserver
Bases: InputWebserver
webserver for Thunderbird mail access via python
Source code in thunderbird/tb_webserver.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
__init__()
Constructor
Source code in thunderbird/tb_webserver.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|
configure_run()
configure me e.g. the allowed urls
Source code in thunderbird/tb_webserver.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
get_config()
classmethod
get the configuration for this Webserver
Source code in thunderbird/tb_webserver.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
get_mail(user, mailid)
Retrieves a specific mail for a given user by its mail identifier.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user |
str
|
The username of the individual whose mail is to be retrieved. |
required |
mailid |
str
|
The unique identifier for the mail to be retrieved. |
required |
Returns:
Name | Type | Description |
---|---|---|
Any |
Any
|
Returns an instance of the Mail class corresponding to the specified |
Raises:
Type | Description |
---|---|
HTTPException
|
If the user is not found in the mail archives, an HTTP exception with status code 404 is raised. |
Source code in thunderbird/tb_webserver.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|
get_part(user, mailid, part_index)
async
Asynchronously retrieves a specific part of a mail for a given user, identified by the mail's unique ID and the part index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user |
str
|
The username of the individual whose mail part is to be retrieved. |
required |
mailid |
str
|
The unique identifier for the mail whose part is to be retrieved. |
required |
part_index |
int
|
The index of the part within the mail to retrieve. |
required |
Returns:
Name | Type | Description |
---|---|---|
FileResponse |
FileResponse
|
A file response object containing the specified part of the mail. |
Raises:
Type | Description |
---|---|
HTTPException
|
If the user or the specified mail part does not exist, an HTTP exception could be raised. |
Source code in thunderbird/tb_webserver.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
version
Created on 2023-11-23
@author: wf
Version
dataclass
Bases: object
Version handling for pyThunderbird
Source code in thunderbird/version.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|