Meta
Representation of the “meta.xml” part.
Classes:
| Name | Description |
|---|---|
Meta |
Representation of the “meta.xml” part. |
Attributes:
| Name | Type | Description |
|---|---|---|
GENERATOR |
|
GENERATOR
module-attribute
GENERATOR = f'odfdo {__version__}'
Meta
Bases: XmlPart, DcCreatorMixin, DcDateMixin
Representation of the “meta.xml” part.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize the Meta XML part. |
as_dict |
Return the metadata of the document as a Python dict. |
as_json |
Return the metadata of the document as a JSON string. |
as_text |
Return meta information as text, with some formatting for |
clear_user_defined_metadata |
Remove all user-defined metadata fields from the document. |
delete_user_defined_metadata_of_name |
Delete all user-defined metadata fields with a specific name. |
from_dict |
Set the metadata of the document from a Python dict. |
get_auto_reload |
Get the MetaAutoReload “meta:auto-reload” element or None. |
get_creation_date |
Get the creation date of the document. |
get_description |
Get the description of the document. Also known as comments. |
get_editing_cycles |
Get the number of times the document was edited, as reported by the |
get_editing_duration |
Get the time the document was edited, as reported by the generator. |
get_generator |
Get the signature of the software that generated this document. |
get_hyperlink_behaviour |
Get the MetaHyperlinkBehaviour “meta:hyperlink-behaviour” element or |
get_initial_creator |
Get the first creator of the document. |
get_keywords |
Get the keywords of the document. Return the field as-is, without |
get_language |
Get the default language of the document BUT only from the metadata, |
get_statistic |
Get the statistics about a document, “meta:document-statistic” tag. |
get_subject |
Get the subject of the document. |
get_template |
Get the MetaTemplate “meta:template” element or None. |
get_title |
Get the title of the document. |
get_user_defined_metadata |
Get all additional user-defined metadata for a document. |
get_user_defined_metadata_of_name |
Return the content of the user defined metadata of that name. Return |
set_auto_reload |
Set or replace the |
set_creation_date |
Set the creation date of the document. |
set_description |
Set the description of the document. Also known as comments. |
set_editing_cycles |
Set the number of times the document was edited. |
set_editing_duration |
Set the time the document was edited. |
set_generator |
Set the signature of the software that generated this document. |
set_generator_default |
Set the signature of the software that generated this document to |
set_hyperlink_behaviour |
Set or replace the |
set_initial_creator |
Set the first creator of the document. |
set_keywords |
Set the keywords of the document. Although the name is plural, a str |
set_language |
Set the default language of the document BUT only in the metadata, |
set_statistic |
Set the statistics about a document, “meta:document-statistic” tag. |
set_subject |
Set the subject of the document. |
set_template |
Set or replace the |
set_title |
Set the title of the document. |
set_user_defined_metadata |
Set a user defined metadata of that name and value. |
strip |
Strip metadata to their minimal content. |
Attributes:
| Name | Type | Description |
|---|---|---|
auto_reload |
MetaAutoReload | None
|
Get the MetaAutoReload “meta:auto-reload” element or None. |
creation_date |
datetime | None
|
Get or set the date and time when a document was created |
description |
str | None
|
Get or set the description of a document |
editing_cycles |
int | None
|
Get or set the number of times a document has been edited |
editing_duration |
timedelta | None
|
Get or set the total time spent editing a document <meta:editing- |
generator |
str | None
|
Get or set the signature of the software that generated this |
get_comments |
|
|
get_meta_body |
|
|
hyperlink_behaviour |
MetaHyperlinkBehaviour | None
|
Get the MetaHyperlinkBehaviour “meta:hyperlink-behaviour” element or |
initial_creator |
str | None
|
Get or set the initial creator of a document |
keyword |
str | None
|
Get or set some keyword(s) keyword pertaining to a document |
keywords |
|
|
language |
str | None
|
Get or set the default language of the document BUT only in the |
meta_body |
Metadata
|
Return the body of the “meta.xml” part. |
odf_office_version |
str
|
Return the “office:version” value of the document. |
print_date |
datetime | None
|
Get or set the date and time when a document when a document was |
printed_by |
str | None
|
Get or set the name of the last person who printed a document. |
set_comments |
|
|
statistic |
dict[str, int] | None
|
Get or set the statistics about a document, “meta:document- |
subject |
str | None
|
Get or set the subject of a document |
template |
MetaTemplate | None
|
Get the MetaTemplate “meta:template” element or None. |
title |
str | None
|
Get or set the title of the document |
user_defined_metadata |
dict[str, Decimal | datetime | date | timedelta | bool | str]
|
Get or set all additional user-defined metadata for a document. |
Source code in odfdo/meta.py
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 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 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 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 722 723 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 774 775 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 1089 1090 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 1163 1164 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 | |
_generator_modified
instance-attribute
_generator_modified: bool = False
auto_reload
property
auto_reload: MetaAutoReload | None
Get the MetaAutoReload “meta:auto-reload” element or None.
Returns:
| Type | Description |
|---|---|
MetaAutoReload | None
|
A MetaAutoReload instance or None. |
creation_date
property
writable
creation_date: datetime | None
Get or set the date and time when a document was created
If provided datetime is None, use current time.
Returns: datetime (or None if inexistent)
description
property
writable
description: str | None
Get or set the description of a document
Returns: str (or None if inexistent)
editing_cycles
property
writable
editing_cycles: int | None
Get or set the number of times a document has been edited
When a document is created, this value is set to 1. Each time a document is saved, the editing-cycles number is incremented by 1.
Returns: int (or None if inexistent)
editing_duration
property
writable
editing_duration: timedelta | None
Get or set the total time spent editing a document
Returns: timedelta (or None if inexistent)
generator
property
writable
generator: str | None
Get or set the signature of the software that generated this document.
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The generator string, or None if inexistent. |
Example::
>>> document.meta.generator
KOffice/2.0.0
>>> document.meta.generator = "Odfdo experiment"
get_comments
class-attribute
instance-attribute
get_comments = get_description
get_meta_body
class-attribute
instance-attribute
get_meta_body = _get_body
hyperlink_behaviour
property
hyperlink_behaviour: MetaHyperlinkBehaviour | None
Get the MetaHyperlinkBehaviour “meta:hyperlink-behaviour” element or None.
Returns:
| Type | Description |
|---|---|
MetaHyperlinkBehaviour | None
|
A MetaHyperlinkBehaviour instance or None. |
initial_creator
property
writable
initial_creator: str | None
Get or set the initial creator of a document
Returns: str (or None if inexistent)
keyword
property
writable
keyword: str | None
Get or set some keyword(s) keyword pertaining to a document
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The keyword string, or None if inexistent. |
keywords
class-attribute
instance-attribute
keywords = keyword
language
property
writable
language: str | None
Get or set the default language of the document BUT only in the metadata, “dc:language”.
To set globally the default language, prefer the Document.language property.
Returns: str (or None if inexistent)
meta_body
property
meta_body: Metadata
Return the body of the “meta.xml” part.
odf_office_version
property
odf_office_version: str
Return the “office:version” value of the document.
print_date
property
writable
print_date: datetime | None
Get or set the date and time when a document when a document was
last printed
If provided datetime is None, use current time.
Returns:
| Type | Description |
|---|---|
datetime | None
|
datetime | None: The print date as a datetime object, or None if inexistent. |
printed_by
property
writable
printed_by: str | None
Get or set the name of the last person who printed a document.
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The printed by string, or None if inexistent. |
set_comments
class-attribute
instance-attribute
set_comments = set_description
statistic
property
writable
statistic: dict[str, int] | None
Get or set the statistics about a document, “meta:document- statistic” tag.
Returns:
| Type | Description |
|---|---|
dict[str, int] | None
|
dict[str, int] | None: The statistics dictionary, or None if inexistent. |
Example::
>>> document.get_statistic():
{'meta:table-count': 1,
'meta:image-count': 2,
'meta:object-count': 3,
'meta:page-count': 4,
'meta:paragraph-count': 5,
'meta:word-count': 6,
'meta:character-count': 7,
'meta:non-whitespace-character-count':3}
subject
property
writable
subject: str | None
Get or set the subject of a document
Returns: str (or None if inexistent)
template
property
template: MetaTemplate | None
Get the MetaTemplate “meta:template” element or None.
Returns:
| Type | Description |
|---|---|
MetaTemplate | None
|
A MetaTemplate instance or None. |
title
property
writable
title: str | None
Get or set the title of the document
Returns: str (or None if inexistent)
user_defined_metadata
property
writable
user_defined_metadata: dict[
str, Decimal | datetime | date | timedelta | bool | str
]
Get or set all additional user-defined metadata for a document.
Return a dict of str/value mapping.
Value types can be: Decimal, datetime, date, timedelta, bool or str.
__init__
__init__(*args: Any, **kwargs: Any) -> None
Initialize the Meta XML part.
This represents the meta.xml file within an ODF document, containing
various document metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Positional arguments passed to the parent |
()
|
**kwargs
|
Any
|
Keyword arguments passed to the parent |
{}
|
Source code in odfdo/meta.py
55 56 57 58 59 60 61 62 63 64 65 66 | |
_as_json_dict
_as_json_dict(full: bool = False) -> dict[str, Any]
Internal method to prepare metadata as a JSON-compatible dictionary.
This converts various Python types (datetime, timedelta, Decimal) into their string representations suitable for JSON serialization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
full
|
bool
|
If True, exports all keys including those with no value assigned. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: A dictionary of metadata ready for JSON serialization. |
Source code in odfdo/meta.py
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 1089 1090 1091 1092 1093 1094 1095 1096 1097 | |
_complete_stats
staticmethod
_complete_stats(
current_stats: dict[str, int],
imported_stats: dict[str, int] | None,
) -> dict[str, int]
Internal helper to merge and complete document statistics.
It takes current statistics and imported statistics, filling in missing values with 0 and prioritizing imported values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_stats
|
dict[str, int]
|
The current document statistics. |
required |
imported_stats
|
dict[str, int] | None
|
The statistics to import, or None. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, int]
|
dict[str, int]: A merged dictionary of statistics. |
Source code in odfdo/meta.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 | |
_get_body
_get_body() -> Metadata
Internal method to get the root office:meta element.
Returns:
| Name | Type | Description |
|---|---|---|
Metadata |
Metadata
|
The |
Source code in odfdo/meta.py
68 69 70 71 72 73 74 | |
_user_defined_metadata_by_name
_user_defined_metadata_by_name(
name: str,
) -> MetaUserDefined | None
Internal helper to find a specific user-defined metadata element by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the user-defined metadata field to find. |
required |
Returns:
| Type | Description |
|---|---|
MetaUserDefined | None
|
MetaUserDefined | None: The |
Source code in odfdo/meta.py
904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 | |
_user_defined_metadata_list
_user_defined_metadata_list() -> list[
dict[
str,
Decimal
| datetime
| dtdate
| timedelta
| bool
| str,
]
]
Internal helper to retrieve all user-defined metadata as a sorted list of dictionaries.
Returns:
| Type | Description |
|---|---|
list[dict[str, Decimal | datetime | date | timedelta | bool | str]]
|
list[dict[str, Any]]: A sorted list of dictionaries, each representing a user-defined metadata field. |
Source code in odfdo/meta.py
857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 | |
as_dict
as_dict(full: bool = False) -> dict[str, Any]
Return the metadata of the document as a Python dict.
if ‘full’ is True, export also the keys with no value assigned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
full
|
bool
|
If True, exports also the keys with no value assigned. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The metadata of the document as a Python dict. |
Source code in odfdo/meta.py
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 | |
as_json
as_json(full: bool = False) -> str
Return the metadata of the document as a JSON string.
if ‘full’ is True, export also the keys with no value assigned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
full
|
bool
|
boolean |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The metadata of the document as a JSON string. |
Source code in odfdo/meta.py
1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 | |
as_text
as_text(no_user_defined_msg: str = '') -> str
Return meta information as text, with some formatting for printing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
no_user_defined_msg
|
str
|
customize the string when no user defined data is present. |
''
|
Returns:
| Type | Description |
|---|---|
str
|
The metadata of the document as a text. |
Source code in odfdo/meta.py
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 1163 | |
clear_user_defined_metadata
clear_user_defined_metadata() -> None
Remove all user-defined metadata fields from the document.
Iteratively deletes all meta:user-defined elements.
Source code in odfdo/meta.py
874 875 876 877 878 879 880 881 882 883 884 | |
delete_user_defined_metadata_of_name
delete_user_defined_metadata_of_name(name: str) -> None
Delete all user-defined metadata fields with a specific name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the user-defined metadata field to delete. |
required |
Source code in odfdo/meta.py
972 973 974 975 976 977 978 979 980 981 982 | |
from_dict
from_dict(data: dict[str, Any]) -> None
Set the metadata of the document from a Python dict.
The loaded metadata are merged with the existing metadata. If the new value of a key is None: - meta:creation-date: use current time, - dc:date: use creation date, - meta:editing-duration: set to zero, - meta:editing-cycles: set to 1, - meta:generator: use odfdo generator string. Other keys (not mandatory keys): remove key/value pair from metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
A dictionary of metadata. |
required |
Source code in odfdo/meta.py
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 | |
get_auto_reload
get_auto_reload() -> MetaAutoReload | None
Get the MetaAutoReload “meta:auto-reload” element or None.
Returns:
| Type | Description |
|---|---|
MetaAutoReload | None
|
A MetaAutoReload instance or None. |
Source code in odfdo/meta.py
395 396 397 398 399 400 401 402 | |
get_creation_date
get_creation_date() -> datetime | None
Get the creation date of the document.
(Also available as “self.creation_date” property.)
Returns:
| Type | Description |
|---|---|
datetime | None
|
datetime | None: The creation date as a datetime object, or None if inexistent. |
Source code in odfdo/meta.py
282 283 284 285 286 287 288 289 290 291 292 293 294 | |
get_description
get_description() -> str | None
Get the description of the document. Also known as comments.
(Also available as “self.description” property.)
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The description string, or None if inexistent. |
Source code in odfdo/meta.py
135 136 137 138 139 140 141 142 143 144 145 146 | |
get_editing_cycles
get_editing_cycles() -> int | None
Get the number of times the document was edited, as reported by the generator.
(Also available as “self.editing_cycles” property.)
Returns:
| Type | Description |
|---|---|
int | None
|
int | None: The number of editing cycles as an integer, or None if inexistent. |
Source code in odfdo/meta.py
633 634 635 636 637 638 639 640 641 642 643 644 645 646 | |
get_editing_duration
get_editing_duration() -> timedelta | None
Get the time the document was edited, as reported by the generator.
(Also available as “self.editing_duration” property.)
Returns:
| Type | Description |
|---|---|
timedelta | None
|
timedelta | None: The editing duration as a timedelta object, or None if inexistent. |
Source code in odfdo/meta.py
590 591 592 593 594 595 596 597 598 599 600 601 602 | |
get_generator
get_generator() -> str | None
Get the signature of the software that generated this document.
(Also available as “self.generator” property.)
Returns:
| Type | Description |
|---|---|
str | None
|
str (or None if inexistent). |
Example::
>>> document.meta.get_generator()
KOffice/2.0.0
Source code in odfdo/meta.py
710 711 712 713 714 715 716 717 718 719 720 721 722 723 | |
get_hyperlink_behaviour
get_hyperlink_behaviour() -> MetaHyperlinkBehaviour | None
Get the MetaHyperlinkBehaviour “meta:hyperlink-behaviour” element or None.
Returns:
| Type | Description |
|---|---|
MetaHyperlinkBehaviour | None
|
A MetaHyperlinkBehaviour instance or None. |
Source code in odfdo/meta.py
430 431 432 433 434 435 436 437 438 439 440 | |
get_initial_creator
get_initial_creator() -> str | None
Get the first creator of the document.
(Also available as “self.initial_creator” property.)
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The initial creator string, or None if inexistent. |
Example::
>>> document.meta.get_initial_creator()
Unknown
Source code in odfdo/meta.py
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | |
get_keywords
get_keywords() -> str | None
Get the keywords of the document. Return the field as-is, without any assumption on the keyword separator.
(Also available as “self.keyword” and “self.keywords” property.)
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The keywords string, or None if inexistent. |
Source code in odfdo/meta.py
545 546 547 548 549 550 551 552 553 554 555 556 557 | |
get_language
get_language() -> str | None
Get the default language of the document BUT only from the metadata, “dc:language”.
Prefer the Document.get_language() function.
(Also available as “self.language” property.)
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The language string, or None if inexistent. |
Example::
>>> document.meta.get_language()
fr-FR
Source code in odfdo/meta.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
get_statistic
get_statistic() -> dict[str, int] | None
Get the statistics about a document, “meta:document-statistic” tag.
(Also available as “self.statistic” property.)
Returns:
| Type | Description |
|---|---|
dict[str, int] | None
|
A dict (or None if inexistent). |
Example::
>>> document.get_statistic():
{'meta:table-count': 1,
'meta:image-count': 2,
'meta:object-count': 3,
'meta:page-count': 4,
'meta:paragraph-count': 5,
'meta:word-count': 6,
'meta:character-count': 7,
'meta:non-whitespace-character-count': 3}
Source code in odfdo/meta.py
750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 | |
get_subject
get_subject() -> str | None
Get the subject of the document.
(Also available as “self.subject” property.)
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The subject string, or None if inexistent. |
Source code in odfdo/meta.py
179 180 181 182 183 184 185 186 187 188 189 190 | |
get_template
get_template() -> MetaTemplate | None
Get the MetaTemplate “meta:template” element or None.
Returns:
| Type | Description |
|---|---|
MetaTemplate | None
|
A MetaTemplate instance or None. |
Source code in odfdo/meta.py
355 356 357 358 359 360 361 362 | |
get_title
get_title() -> str | None
Get the title of the document.
This is not the first heading but the title metadata.
(Also available as “self.title” property.)
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The title string, or None if inexistent. |
Source code in odfdo/meta.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
get_user_defined_metadata
get_user_defined_metadata() -> dict[
str,
Decimal | datetime | dtdate | timedelta | bool | str,
]
Get all additional user-defined metadata for a document.
(Also available as “self.user_defined_metadata” property.)
Returns:
| Type | Description |
|---|---|
dict[str, Decimal | datetime | date | timedelta | bool | str]
|
A dict of str/value mapping. |
Value types can be: Decimal, datetime, date, timedelta, bool or str.
Source code in odfdo/meta.py
838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 | |
get_user_defined_metadata_of_name
get_user_defined_metadata_of_name(
keyname: str,
) -> dict[str, Any] | None
Return the content of the user defined metadata of that name. Return None if no name matches or a dic of fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keyname
|
str
|
The name of the user-defined metadata field to find. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
dict[str, Any]: A dict with keys “name”, “value”, “value_type”, “text”. |
Source code in odfdo/meta.py
921 922 923 924 925 926 927 928 929 930 931 932 933 934 | |
set_auto_reload
set_auto_reload(delay: timedelta, href: str = '') -> None
Set or replace the meta:auto-reload element.
This specifies whether a document is reloaded or replaced by another
document after a specified period of time. Any existing
meta:auto-reload element will be removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
delay
|
timedelta
|
The time delay after which the document should auto-reload. |
required |
href
|
str
|
The URL or path to the document to reload or replace with. |
''
|
Source code in odfdo/meta.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | |
set_creation_date
set_creation_date(date: datetime | None = None) -> None
Set the creation date of the document.
If provided datetime is None, use current time.
(Also available as “self.creation_date” property.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
datetime | None
|
The datetime object to set as the creation date. |
None
|
Source code in odfdo/meta.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | |
set_description
set_description(description: str) -> None
Set the description of the document. Also known as comments.
(Also available as “self.description” property.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
description
|
str
|
The description string to set. |
required |
Source code in odfdo/meta.py
151 152 153 154 155 156 157 158 159 160 161 162 163 | |
set_editing_cycles
set_editing_cycles(cycles: int) -> None
Set the number of times the document was edited.
(Also available as “self.editing_cycles” property.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cycles
|
int
|
The number of editing cycles to set. |
required |
Source code in odfdo/meta.py
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | |
set_editing_duration
set_editing_duration(duration: timedelta) -> None
Set the time the document was edited.
(Also available as “self.editing_duration” property.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
duration
|
timedelta
|
The timedelta object representing the editing duration. |
required |
Source code in odfdo/meta.py
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 | |
set_generator
set_generator(generator: str) -> None
Set the signature of the software that generated this document.
(Also available as “self.generator” property.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
generator
|
str
|
The generator string to set. |
required |
Example::
>>> document.meta.set_generator("Odfdo experiment")
Source code in odfdo/meta.py
725 726 727 728 729 730 731 732 733 734 735 736 737 | |
set_generator_default
set_generator_default() -> None
Set the signature of the software that generated this document to ourself.
Example::
>>> document.meta.set_generator_default()
Source code in odfdo/meta.py
739 740 741 742 743 744 745 746 747 748 | |
set_hyperlink_behaviour
set_hyperlink_behaviour(
target_frame_name: str = "_blank", show: str = "replace"
) -> None
Set or replace the meta:hyperlink-behaviour element.
This specifies the default behavior for hyperlinks in a document.
Any existing meta:hyperlink-behaviour element will be removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_frame_name
|
str
|
The name of the target frame for the hyperlink. Defaults to “_blank” (new window/tab). |
'_blank'
|
show
|
str
|
Specifies how the target resource is presented. Defaults to “replace”. |
'replace'
|
Source code in odfdo/meta.py
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | |
set_initial_creator
set_initial_creator(creator: str) -> None
Set the first creator of the document.
(Also available as “self.initial_creator” property.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
creator
|
str
|
The creator string to set. |
required |
Example::
>>> document.meta.set_initial_creator("Plato")
Source code in odfdo/meta.py
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 | |
set_keywords
set_keywords(keywords: str) -> None
Set the keywords of the document. Although the name is plural, a str string is required, so join your list first.
(Also available as “self.keyword” and “self.keywords” property.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keywords
|
str
|
The keywords string to set. |
required |
Source code in odfdo/meta.py
559 560 561 562 563 564 565 566 567 568 569 570 571 572 | |
set_language
set_language(language: str) -> None
Set the default language of the document BUT only in the metadata, “dc:language”.
To set globally the default language, prefer the Document.set_language() function.
(Also available as “self.language” property.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
language
|
str
|
The language string to set. |
required |
Example::
>>> document.meta.set_language('fr-FR')
Source code in odfdo/meta.py
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 | |
set_statistic
set_statistic(statistic: dict[str, int]) -> None
Set the statistics about a document, “meta:document-statistic” tag.
(Also available as “self.statistic” property.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
statistic
|
dict[str, int]
|
The statistics dictionary to set. |
required |
Example::
>>> statistic = {'meta:table-count': 1,
'meta:image-count': 2,
'meta:object-count': 3,
'meta:page-count': 4,
'meta:paragraph-count': 5,
'meta:word-count': 6,
'meta:character-count': 7,
'meta:non-whitespace-character-count': 3}
>>> document.meta.set_statistic(statistic)
Source code in odfdo/meta.py
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 | |
set_subject
set_subject(subject: str) -> None
Set the subject of the document.
(Also available as “self.subject” property.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject
|
str
|
The subject string to set. |
required |
Source code in odfdo/meta.py
192 193 194 195 196 197 198 199 200 201 202 203 204 | |
set_template
set_template(
date: datetime | None = None,
href: str = "",
title: str = "",
) -> None
Set or replace the meta:template element.
This specifies the document template used to create the current document.
Any existing meta:template element will be removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
datetime | None
|
The date and time when the template was used. |
None
|
href
|
str
|
The URI for the document template (XLink). |
''
|
title
|
str
|
The title of the document template (XLink). |
''
|
Source code in odfdo/meta.py
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
set_title
set_title(title: str) -> None
Set the title of the document.
This is not the first heading but the title metadata.
(Also available as “self.title” property.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
The title string to set. |
required |
Source code in odfdo/meta.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
set_user_defined_metadata
set_user_defined_metadata(
name: str,
value: bool
| int
| float
| Decimal
| datetime
| date
| str
| timedelta
| None,
) -> None
Set a user defined metadata of that name and value.
If value is None, any existing metadata of that name is deleted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the user-defined metadata field. |
required |
value
|
bool | int | float | Decimal | datetime | date | str | timedelta | None
|
The value to set for the metadata field. Can be a boolean, int, float, Decimal, datetime, date, string, timedelta, or None for deletion. |
required |
Source code in odfdo/meta.py
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 | |
strip
strip(
generator: str = GENERATOR,
creation_date: datetime | None = None,
) -> None
Strip metadata to their minimal content.
All user defined metadata are removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
generator
|
str
|
String for the meta:generator field. |
GENERATOR
|
creation_date
|
datetime | None
|
Datetime or None, meta:creation-date value. |
None
|
Source code in odfdo/meta.py
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 | |