Meta User Defined
MetaUserDefined class for “meta:user-defined” tag.
Classes:
| Name | Description |
|---|---|
MetaUserDefined |
Declaration of a user-defined metadata, “meta:user-defined”. |
MetaUserDefined
Bases: Element
Declaration of a user-defined metadata, “meta:user-defined”.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize a MetaUserDefined element. |
as_dict |
Return the user-defined metadata as a dictionary. |
as_dict_full |
Return the user-defined metadata as a detailed dictionary. |
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Get the name of the user-defined metadata field. |
value |
Decimal | datetime | date | timedelta | bool | str
|
Get the Python-typed value of the user-defined metadata field. |
value_type |
str
|
Get the type of the user-defined value. |
Source code in odfdo/meta_user_defined.py
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 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 | |
_tag
class-attribute
instance-attribute
_tag = 'meta:user-defined'
name
property
writable
name: str
Get the name of the user-defined metadata field.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The value of the |
value
property
writable
value: Decimal | datetime | date | timedelta | bool | str
Get the Python-typed value of the user-defined metadata field.
The return type depends on the meta:value-type attribute.
Returns:
| Type | Description |
|---|---|
Decimal | datetime | date | timedelta | bool | str
|
Decimal | datetime | dtdate | timedelta | bool | str: The converted value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the |
value_type
property
writable
value_type: str
Get the type of the user-defined value.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The value of the |
__init__
__init__(
name: str | None = None,
value_type: str | None = None,
value: int
| float
| Decimal
| datetime
| date
| timedelta
| bool
| str
| None = None,
**kwargs: Any,
) -> None
Initialize a MetaUserDefined element.
This element declares a user-defined metadata field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The name of the user-defined metadata field
(corresponds to |
None
|
value_type
|
str | None
|
The type of the value. Must be one of “boolean”, “date”, “float”, “time”, “string”. |
None
|
value
|
int | float | Decimal | datetime | date | timedelta | bool | str | None
|
The actual value of the user-defined metadata. |
None
|
**kwargs
|
Any
|
Additional keyword arguments for the parent |
{}
|
Source code in odfdo/meta_user_defined.py
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 | |
_value_to_value_type
staticmethod
_value_to_value_type(
value: bool
| int
| float
| Decimal
| datetime
| date
| str
| timedelta,
) -> str
Internal helper to infer the ODF value type from a Python value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
bool | int | float | Decimal | datetime | date | str | timedelta
|
The Python value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The inferred ODF value type (“boolean”, “float”, “date”, “string”, or “time”). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the type of the provided value is not supported. |
Source code in odfdo/meta_user_defined.py
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 | |
as_dict
as_dict() -> dict[
str,
Decimal | datetime | dtdate | timedelta | bool | str,
]
Return the user-defined metadata as a dictionary.
Returns:
| Type | Description |
|---|---|
dict[str, Decimal | datetime | date | timedelta | bool | str]
|
dict[str, Decimal | datetime | dtdate | timedelta | bool | str]: A dictionary containing “meta:name”, “meta:value-type”, and “value”. |
Source code in odfdo/meta_user_defined.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
as_dict_full
as_dict_full() -> dict[
str,
Decimal | datetime | dtdate | timedelta | bool | str,
]
Return the user-defined metadata as a detailed dictionary.
This includes the name, value type, value, and raw text content.
Returns:
| Type | Description |
|---|---|
dict[str, Decimal | datetime | date | timedelta | bool | str]
|
dict[str, Decimal | datetime | dtdate | timedelta | bool | str]: A dictionary containing “name”, “value_type”, “value”, and “text”. |
Source code in odfdo/meta_user_defined.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |