Skip to content

Config Elements

Config elements for the “settings.xml” part.

This module defines classes representing configuration elements found within the settings.xml file of an ODF document, specifically those related to config:config-item-set.

Classes:

Name Description
ConfigItem

Represents an element containing the value of an application setting,

ConfigItemMapEntry

Represents a single setting entry in a sequence of settings,

ConfigItemMapIndexed

Represents a container for ordered sequences of application settings,

ConfigItemMapNamed

Represents a container for a sequence of application setting elements,

ConfigItemSet

Represents a container element for application setting elements,

ConfigItem

Bases: Element

Represents an element containing the value of an application setting, identified by its config:name attribute. This corresponds to the “config:config-item” tag.

This element holds a single configuration value and does not have any child elements.

Attributes:

Name Type Description
name str

The name of the configuration item.

config_type str

The data type of the configuration item’s value.

value str | int | bool

The actual value of the configuration item.

Methods:

Name Description
__init__

Initialize a ConfigItem element.

__repr__
as_dict

Serialize the element to a dictionary.

from_dict

Create an element from a dictionary.

Source code in odfdo/config_elements.py
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
class ConfigItem(Element):
    """Represents an element containing the value of an application setting,
    identified by its `config:name` attribute. This corresponds to the
    "config:config-item" tag.

    This element holds a single configuration value and does not have any
    child elements.

    Attributes:
        name (str): The name of the configuration item.
        config_type (str): The data type of the configuration item's value.
        value (str | int | bool): The actual value of the configuration item.
    """

    _tag: str = "config:config-item"
    _properties: tuple[PropDef | PropDefBool, ...] = (
        PropDef("name", "config:name"),
        PropDef("config_type", "config:type"),
    )
    _properties = (PropDef("name", "config:name"),)
    TYPES: ClassVar = {
        "boolean",
        "short",
        "int",
        "long",
        "double",
        "string",
        "datetime",
        "base64Binary",
    }

    def __init__(
        self,
        name: str | None = None,
        config_type: str | None = None,
        value: str | int | bool | None = None,
        **kwargs: Any,
    ) -> None:
        """Initialize a ConfigItem element.

        This element contains the value of an application setting.

        Args:
            name: The name of the configuration item.
            config_type: The data type of the configuration item's value,
                one of "boolean", "short", "int", "long", "double", "string",
                "datetime", or "base64Binary".
            value: The actual value of the configuration item.
        """
        super().__init__(**kwargs)
        if self._do_init:
            self.name = name
            self.config_type = config_type
            self.value = value

    def __repr__(self) -> str:
        return f"<{self.__class__.__name__} tag={self.tag} name={self.name}>"

    @property
    def config_type(self) -> str:
        """Get the data type of the configuration item's value."""
        config_type = self.get_attribute_string("config:type")
        if config_type not in self.TYPES:
            return "string"
        return config_type

    @config_type.setter
    def config_type(self, config_type: str | None) -> None:
        """Set the data type of the configuration item's value."""
        if config_type not in self.TYPES:
            config_type = "string"
        self._set_attribute_str("config:type", config_type)

    @property
    def value(self) -> str | int | bool:
        """Get or set the value of the configuration item.

        When getting, the value is cast to its appropriate Python type (str,
        int, or bool) based on the `config_type` attribute.

        When setting, the provided value is converted to a string and stored
        as the element's text content, applying type-specific encoding (e.g.,
        for booleans) based on the `config_type` attribute.

        Returns:
            The value of the configuration item as a str, int, or bool.
        """
        content: str = self.text
        config_type = self.config_type
        if config_type == "boolean":
            return Boolean.decode(content)
        elif config_type in {"short", "int", "long", "double"}:
            return int(content)
        return content or ""

    @value.setter
    def value(self, value: str | int | bool | None) -> None:
        config_type = self.config_type
        if config_type == "boolean":
            self.text = Boolean.encode(value)
        elif config_type in {"short", "int", "long", "double"}:
            self.text = str(int(value))  # type: ignore[arg-type]
        else:
            self.text = str(value or "")

    def as_dict(self) -> dict[str, str | int | bool]:
        """Serialize the element to a dictionary.

        Returns:
            A dict with content of the ConfigItem serialized.
        """
        return {
            "class": self._tag,
            "config:name": self.name,  # type: ignore[dict-item]
            "config:type": self.config_type,
            "value": self.value,
        }

    @classmethod
    def from_dict(cls, data: dict[str, str | int | bool]) -> ConfigItem:
        """Create an element from a dictionary.

        Args:
            data: The  ConfigItem content serialized in a dict.

        Returns:
            A ConfigItem instance."
        """
        return cls(
            name=data["config:name"],  # type: ignore[arg-type]
            config_type=data.get("config:type"),  # type: ignore[arg-type]
            value=data.get("value"),
        )

TYPES class-attribute instance-attribute

TYPES: ClassVar = {
    "boolean",
    "short",
    "int",
    "long",
    "double",
    "string",
    "datetime",
    "base64Binary",
}

_properties class-attribute instance-attribute

_properties: tuple[PropDef | PropDefBool, ...] = (
    PropDef("name", "config:name"),
)

_tag class-attribute instance-attribute

_tag: str = 'config:config-item'

config_type property writable

config_type: str

Get the data type of the configuration item’s value.

name instance-attribute

name = name

value property writable

value: str | int | bool

Get or set the value of the configuration item.

When getting, the value is cast to its appropriate Python type (str, int, or bool) based on the config_type attribute.

When setting, the provided value is converted to a string and stored as the element’s text content, applying type-specific encoding (e.g., for booleans) based on the config_type attribute.

Returns:

Type Description
str | int | bool

The value of the configuration item as a str, int, or bool.

__init__

__init__(
    name: str | None = None,
    config_type: str | None = None,
    value: str | int | bool | None = None,
    **kwargs: Any,
) -> None

Initialize a ConfigItem element.

This element contains the value of an application setting.

Parameters:

Name Type Description Default
name str | None

The name of the configuration item.

None
config_type str | None

The data type of the configuration item’s value, one of “boolean”, “short”, “int”, “long”, “double”, “string”, “datetime”, or “base64Binary”.

None
value str | int | bool | None

The actual value of the configuration item.

None
Source code in odfdo/config_elements.py
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
def __init__(
    self,
    name: str | None = None,
    config_type: str | None = None,
    value: str | int | bool | None = None,
    **kwargs: Any,
) -> None:
    """Initialize a ConfigItem element.

    This element contains the value of an application setting.

    Args:
        name: The name of the configuration item.
        config_type: The data type of the configuration item's value,
            one of "boolean", "short", "int", "long", "double", "string",
            "datetime", or "base64Binary".
        value: The actual value of the configuration item.
    """
    super().__init__(**kwargs)
    if self._do_init:
        self.name = name
        self.config_type = config_type
        self.value = value

__repr__

__repr__() -> str
Source code in odfdo/config_elements.py
492
493
def __repr__(self) -> str:
    return f"<{self.__class__.__name__} tag={self.tag} name={self.name}>"

as_dict

as_dict() -> dict[str, str | int | bool]

Serialize the element to a dictionary.

Returns:

Type Description
dict[str, str | int | bool]

A dict with content of the ConfigItem serialized.

Source code in odfdo/config_elements.py
542
543
544
545
546
547
548
549
550
551
552
553
def as_dict(self) -> dict[str, str | int | bool]:
    """Serialize the element to a dictionary.

    Returns:
        A dict with content of the ConfigItem serialized.
    """
    return {
        "class": self._tag,
        "config:name": self.name,  # type: ignore[dict-item]
        "config:type": self.config_type,
        "value": self.value,
    }

from_dict classmethod

from_dict(data: dict[str, str | int | bool]) -> ConfigItem

Create an element from a dictionary.

Parameters:

Name Type Description Default
data dict[str, str | int | bool]

The ConfigItem content serialized in a dict.

required

Returns:

Type Description
ConfigItem

A ConfigItem instance.”

Source code in odfdo/config_elements.py
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
@classmethod
def from_dict(cls, data: dict[str, str | int | bool]) -> ConfigItem:
    """Create an element from a dictionary.

    Args:
        data: The  ConfigItem content serialized in a dict.

    Returns:
        A ConfigItem instance."
    """
    return cls(
        name=data["config:name"],  # type: ignore[arg-type]
        config_type=data.get("config:type"),  # type: ignore[arg-type]
        value=data.get("value"),
    )

ConfigItemMapEntry

Bases: Element

Represents a single setting entry in a sequence of settings, corresponding to the “config:config-item-map-entry” tag.

The setting itself is defined by the child element of “config:config-item-map-entry”, and may be a single value, a set of settings, or a sequence of settings.

The “config:config-item-map-entry” element has the following child elements: “config:config-item”, “config:config-item-map-indexed”, “config:config-item-map-named”, and “config:config-item-set.

Attributes:

Name Type Description
name str

The name of the entry.

Methods:

Name Description
__init__

Initialize a ConfigItemMapEntry element.

__repr__
as_dict

Serialize the element to a dictionary.

from_dict

Create an element from a dictionary.

Source code in odfdo/config_elements.py
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
class ConfigItemMapEntry(Element):
    """Represents a single setting entry in a sequence of settings,
    corresponding to the "config:config-item-map-entry" tag.

    The setting itself is defined by the child element of "config:config-item-map-entry",
    and may be a single value, a set of settings, or a sequence of settings.

    The "config:config-item-map-entry" element has the following child elements:
    "config:config-item", "config:config-item-map-indexed", "config:config-item-map-named",
    and "config:config-item-set.

    Attributes:
        name (str): The name of the entry.
    """

    _tag: str = "config:config-item-map-entry"
    _properties: tuple[PropDef | PropDefBool, ...] = (PropDef("name", "config:name"),)

    def __init__(
        self,
        name: str | None = None,
        **kwargs: Any,
    ) -> None:
        """Initialize a ConfigItemMapEntry element.

        This represents an entry within an ordered configuration map.

        Args:
            name: The name of the entry.
        """
        super().__init__(**kwargs)
        if self._do_init:
            self.name = name

    def __repr__(self) -> str:
        return f"<{self.__class__.__name__} tag={self.tag} name={self.name}>"

    @property
    def config_item_sets(self) -> list[ConfigItemSet]:
        """Get the list of nested ConfigItemSet elements.

        Returns:
            list[ConfigItemSet]: A list of `ConfigItemSet` objects.
        """
        return cast(list[ConfigItemSet], self.get_elements("config:config-item-set"))

    @property
    def config_item_maps_indexed(self) -> list[ConfigItemMapIndexed]:
        """Get the list of indexed configuration item maps.

        Returns:
            list[ConfigItemMapIndexed]: A list of `ConfigItemMapIndexed`
                objects.
        """
        return cast(
            list[ConfigItemMapIndexed],
            self.get_elements("config:config-item-map-indexed"),
        )

    @property
    def config_item_maps_named(self) -> list[ConfigItemMapNamed]:
        """Get the list of named configuration item maps.

        Returns:
            list[ConfigItemMapNamed]: A list of `ConfigItemMapNamed` objects.
        """
        return cast(
            list[ConfigItemMapNamed], self.get_elements("config:config-item-map-named")
        )

    @property
    def config_items(self) -> list[ConfigItem]:
        """Get the list of individual configuration items.

        Returns:
            list[ConfigItem]: A list of `ConfigItem` objects.
        """
        return cast(list[ConfigItem], self.get_elements("config:config-item"))

    def as_dict(self) -> dict[str, str | int | bool | list[Any] | dict[str, Any]]:
        """Serialize the element to a dictionary.

        Returns:
            A dict with content of the ConfigItemMapEntry serialized."""
        return _as_dict(self)

    @classmethod
    def from_dict(
        cls, data: dict[str, str | int | bool | dict[str, Any]]
    ) -> ConfigItemMapEntry:
        """Create an element from a dictionary.

        Args:
            data: The ConfigItemMapEntry content serialized as a dict.

        Returns:
            A ConfigItemMapEntry.
        """
        return cast(ConfigItemMapEntry, _from_dict(data))

_properties class-attribute instance-attribute

_properties: tuple[PropDef | PropDefBool, ...] = (
    PropDef("name", "config:name"),
)

_tag class-attribute instance-attribute

_tag: str = 'config:config-item-map-entry'

config_item_maps_indexed property

config_item_maps_indexed: list[ConfigItemMapIndexed]

Get the list of indexed configuration item maps.

Returns:

Type Description
list[ConfigItemMapIndexed]

list[ConfigItemMapIndexed]: A list of ConfigItemMapIndexed objects.

config_item_maps_named property

config_item_maps_named: list[ConfigItemMapNamed]

Get the list of named configuration item maps.

Returns:

Type Description
list[ConfigItemMapNamed]

list[ConfigItemMapNamed]: A list of ConfigItemMapNamed objects.

config_item_sets property

config_item_sets: list[ConfigItemSet]

Get the list of nested ConfigItemSet elements.

Returns:

Type Description
list[ConfigItemSet]

list[ConfigItemSet]: A list of ConfigItemSet objects.

config_items property

config_items: list[ConfigItem]

Get the list of individual configuration items.

Returns:

Type Description
list[ConfigItem]

list[ConfigItem]: A list of ConfigItem objects.

name instance-attribute

name = name

__init__

__init__(name: str | None = None, **kwargs: Any) -> None

Initialize a ConfigItemMapEntry element.

This represents an entry within an ordered configuration map.

Parameters:

Name Type Description Default
name str | None

The name of the entry.

None
Source code in odfdo/config_elements.py
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
def __init__(
    self,
    name: str | None = None,
    **kwargs: Any,
) -> None:
    """Initialize a ConfigItemMapEntry element.

    This represents an entry within an ordered configuration map.

    Args:
        name: The name of the entry.
    """
    super().__init__(**kwargs)
    if self._do_init:
        self.name = name

__repr__

__repr__() -> str
Source code in odfdo/config_elements.py
293
294
def __repr__(self) -> str:
    return f"<{self.__class__.__name__} tag={self.tag} name={self.name}>"

as_dict

as_dict() -> dict[
    str, str | int | bool | list[Any] | dict[str, Any]
]

Serialize the element to a dictionary.

Returns:

Type Description
dict[str, str | int | bool | list[Any] | dict[str, Any]]

A dict with content of the ConfigItemMapEntry serialized.

Source code in odfdo/config_elements.py
338
339
340
341
342
343
def as_dict(self) -> dict[str, str | int | bool | list[Any] | dict[str, Any]]:
    """Serialize the element to a dictionary.

    Returns:
        A dict with content of the ConfigItemMapEntry serialized."""
    return _as_dict(self)

from_dict classmethod

from_dict(
    data: dict[str, str | int | bool | dict[str, Any]],
) -> ConfigItemMapEntry

Create an element from a dictionary.

Parameters:

Name Type Description Default
data dict[str, str | int | bool | dict[str, Any]]

The ConfigItemMapEntry content serialized as a dict.

required

Returns:

Type Description
ConfigItemMapEntry

A ConfigItemMapEntry.

Source code in odfdo/config_elements.py
345
346
347
348
349
350
351
352
353
354
355
356
357
@classmethod
def from_dict(
    cls, data: dict[str, str | int | bool | dict[str, Any]]
) -> ConfigItemMapEntry:
    """Create an element from a dictionary.

    Args:
        data: The ConfigItemMapEntry content serialized as a dict.

    Returns:
        A ConfigItemMapEntry.
    """
    return cast(ConfigItemMapEntry, _from_dict(data))

ConfigItemMapIndexed

Bases: Element

Represents a container for ordered sequences of application settings, corresponding to the “config:config-item-map-indexed” tag.

This element is used to store a collection of configuration items that are ordered and can be accessed by index.

Attributes:

Name Type Description
name str

The name of the indexed configuration item map.

Methods:

Name Description
__init__

Initialize a ConfigItemMapIndexed element.

__repr__
as_dict

Serialize the element to a dictionary.

from_dict

Create an element from a dictionary.

Source code in odfdo/config_elements.py
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
class ConfigItemMapIndexed(Element):
    """Represents a container for ordered sequences of application settings,
    corresponding to the "config:config-item-map-indexed" tag.

    This element is used to store a collection of configuration items that are
    ordered and can be accessed by index.

    Attributes:
        name (str): The name of the indexed configuration item map.
    """

    _tag: str = "config:config-item-map-indexed"
    _properties: tuple[PropDef | PropDefBool, ...] = (PropDef("name", "config:name"),)

    def __init__(
        self,
        name: str | None = None,
        **kwargs: Any,
    ) -> None:
        """Initialize a ConfigItemMapIndexed element.

        This container holds ordered sequences of application settings.

        The "config:config-item-map-indexed" element has the following child
        element: "config:config-item-map-entry".

        Args:
            name: The name of the indexed configuration item map.
        """
        super().__init__(**kwargs)
        if self._do_init:
            self.name = name

    def __repr__(self) -> str:
        return f"<{self.__class__.__name__} tag={self.tag} name={self.name}>"

    @property
    def config_item_maps_entries(self) -> list[ConfigItemMapEntry]:
        """Get the list of configuration item map entries.

        Returns:
            list[ConfigItemMapEntry]: A list of `ConfigItemMapEntry` objects.
        """
        return cast(
            list[ConfigItemMapEntry], self.get_elements("config:config-item-map-entry")
        )

    def as_dict(self) -> dict[str, str | int | bool | list[Any] | dict[str, Any]]:
        """Serialize the element to a dictionary.

        Returns:
            A dict with content of the ConfigItemMapIndexed serialized.
        """
        return _as_dict(self)

    @classmethod
    def from_dict(
        cls, data: dict[str, str | int | bool | dict[str, Any]]
    ) -> ConfigItemMapIndexed:
        """Create an element from a dictionary.

        Args:
            data: The ConfigItemMapIndexed content serialized as a dict.

        Returns:
            A ConfigItemMapIndexed.
        """
        return cast(ConfigItemMapIndexed, _from_dict(data))

_properties class-attribute instance-attribute

_properties: tuple[PropDef | PropDefBool, ...] = (
    PropDef("name", "config:name"),
)

_tag class-attribute instance-attribute

_tag: str = 'config:config-item-map-indexed'

config_item_maps_entries property

config_item_maps_entries: list[ConfigItemMapEntry]

Get the list of configuration item map entries.

Returns:

Type Description
list[ConfigItemMapEntry]

list[ConfigItemMapEntry]: A list of ConfigItemMapEntry objects.

name instance-attribute

name = name

__init__

__init__(name: str | None = None, **kwargs: Any) -> None

Initialize a ConfigItemMapIndexed element.

This container holds ordered sequences of application settings.

The “config:config-item-map-indexed” element has the following child element: “config:config-item-map-entry”.

Parameters:

Name Type Description Default
name str | None

The name of the indexed configuration item map.

None
Source code in odfdo/config_elements.py
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
def __init__(
    self,
    name: str | None = None,
    **kwargs: Any,
) -> None:
    """Initialize a ConfigItemMapIndexed element.

    This container holds ordered sequences of application settings.

    The "config:config-item-map-indexed" element has the following child
    element: "config:config-item-map-entry".

    Args:
        name: The name of the indexed configuration item map.
    """
    super().__init__(**kwargs)
    if self._do_init:
        self.name = name

__repr__

__repr__() -> str
Source code in odfdo/config_elements.py
219
220
def __repr__(self) -> str:
    return f"<{self.__class__.__name__} tag={self.tag} name={self.name}>"

as_dict

as_dict() -> dict[
    str, str | int | bool | list[Any] | dict[str, Any]
]

Serialize the element to a dictionary.

Returns:

Type Description
dict[str, str | int | bool | list[Any] | dict[str, Any]]

A dict with content of the ConfigItemMapIndexed serialized.

Source code in odfdo/config_elements.py
233
234
235
236
237
238
239
def as_dict(self) -> dict[str, str | int | bool | list[Any] | dict[str, Any]]:
    """Serialize the element to a dictionary.

    Returns:
        A dict with content of the ConfigItemMapIndexed serialized.
    """
    return _as_dict(self)

from_dict classmethod

from_dict(
    data: dict[str, str | int | bool | dict[str, Any]],
) -> ConfigItemMapIndexed

Create an element from a dictionary.

Parameters:

Name Type Description Default
data dict[str, str | int | bool | dict[str, Any]]

The ConfigItemMapIndexed content serialized as a dict.

required

Returns:

Type Description
ConfigItemMapIndexed

A ConfigItemMapIndexed.

Source code in odfdo/config_elements.py
241
242
243
244
245
246
247
248
249
250
251
252
253
@classmethod
def from_dict(
    cls, data: dict[str, str | int | bool | dict[str, Any]]
) -> ConfigItemMapIndexed:
    """Create an element from a dictionary.

    Args:
        data: The ConfigItemMapIndexed content serialized as a dict.

    Returns:
        A ConfigItemMapIndexed.
    """
    return cast(ConfigItemMapIndexed, _from_dict(data))

ConfigItemMapNamed

Bases: Element

Represents a container for a sequence of application setting elements, where each sequence is identified by the value of its config:name attribute. This corresponds to the “config:config-item-map-named” tag.

This element is used to store a collection of configuration items that can be accessed by a descriptive name rather than an index.

The “config:config-item-map-named” element has the following child element: “config:config-item-map-entry”.

Attributes:

Name Type Description
name str

The name of the named configuration item map.

Methods:

Name Description
__init__

Initialize a ConfigItemMapNamed element.

__repr__
as_dict

Serialize the element to a dictionary.

from_dict

Create an element from a dictionary.

Source code in odfdo/config_elements.py
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
class ConfigItemMapNamed(Element):
    """Represents a container for a sequence of application setting elements,
    where each sequence is identified by the value of its `config:name`
    attribute. This corresponds to the "config:config-item-map-named" tag.

    This element is used to store a collection of configuration items that
    can be accessed by a descriptive name rather than an index.

    The "config:config-item-map-named" element has the following child
    element: "config:config-item-map-entry".

    Attributes:
        name (str): The name of the named configuration item map.
    """

    _tag: str = "config:config-item-map-named"
    _properties: tuple[PropDef | PropDefBool, ...] = (PropDef("name", "config:name"),)

    def __init__(
        self,
        name: str | None = None,
        **kwargs: Any,
    ) -> None:
        """Initialize a ConfigItemMapNamed element.

        This container holds named sequences of application setting elements.

        Args:
            name: The name of the named configuration item map.
        """
        super().__init__(**kwargs)
        if self._do_init:
            self.name = name

    def __repr__(self) -> str:
        return f"<{self.__class__.__name__} tag={self.tag} name={self.name}>"

    @property
    def config_item_maps_entries(self) -> list[ConfigItemMapEntry]:
        """Get the list of configuration item map entries.

        Returns:
            list[ConfigItemMapEntry]: A list of `ConfigItemMapEntry` objects.
        """
        return cast(
            list[ConfigItemMapEntry], self.get_elements("config:config-item-map-entry")
        )

    def as_dict(self) -> dict[str, str | int | bool | list[Any] | dict[str, Any]]:
        """Serialize the element to a dictionary.

        Returns:
            A dict with content of the ConfigItemMapNamed serialized.
        """
        return _as_dict(self)

    @classmethod
    def from_dict(
        cls, data: dict[str, str | int | bool | dict[str, Any]]
    ) -> ConfigItemMapNamed:
        """Create an element from a dictionary.

        Args:
            data: The ConfigItemMapNamed content serialized as a dict.

        Returns:
            A ConfigItemMapNamed.
        """
        return cast(ConfigItemMapNamed, _from_dict(data))

_properties class-attribute instance-attribute

_properties: tuple[PropDef | PropDefBool, ...] = (
    PropDef("name", "config:name"),
)

_tag class-attribute instance-attribute

_tag: str = 'config:config-item-map-named'

config_item_maps_entries property

config_item_maps_entries: list[ConfigItemMapEntry]

Get the list of configuration item map entries.

Returns:

Type Description
list[ConfigItemMapEntry]

list[ConfigItemMapEntry]: A list of ConfigItemMapEntry objects.

name instance-attribute

name = name

__init__

__init__(name: str | None = None, **kwargs: Any) -> None

Initialize a ConfigItemMapNamed element.

This container holds named sequences of application setting elements.

Parameters:

Name Type Description Default
name str | None

The name of the named configuration item map.

None
Source code in odfdo/config_elements.py
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
def __init__(
    self,
    name: str | None = None,
    **kwargs: Any,
) -> None:
    """Initialize a ConfigItemMapNamed element.

    This container holds named sequences of application setting elements.

    Args:
        name: The name of the named configuration item map.
    """
    super().__init__(**kwargs)
    if self._do_init:
        self.name = name

__repr__

__repr__() -> str
Source code in odfdo/config_elements.py
397
398
def __repr__(self) -> str:
    return f"<{self.__class__.__name__} tag={self.tag} name={self.name}>"

as_dict

as_dict() -> dict[
    str, str | int | bool | list[Any] | dict[str, Any]
]

Serialize the element to a dictionary.

Returns:

Type Description
dict[str, str | int | bool | list[Any] | dict[str, Any]]

A dict with content of the ConfigItemMapNamed serialized.

Source code in odfdo/config_elements.py
411
412
413
414
415
416
417
def as_dict(self) -> dict[str, str | int | bool | list[Any] | dict[str, Any]]:
    """Serialize the element to a dictionary.

    Returns:
        A dict with content of the ConfigItemMapNamed serialized.
    """
    return _as_dict(self)

from_dict classmethod

from_dict(
    data: dict[str, str | int | bool | dict[str, Any]],
) -> ConfigItemMapNamed

Create an element from a dictionary.

Parameters:

Name Type Description Default
data dict[str, str | int | bool | dict[str, Any]]

The ConfigItemMapNamed content serialized as a dict.

required

Returns:

Type Description
ConfigItemMapNamed

A ConfigItemMapNamed.

Source code in odfdo/config_elements.py
419
420
421
422
423
424
425
426
427
428
429
430
431
@classmethod
def from_dict(
    cls, data: dict[str, str | int | bool | dict[str, Any]]
) -> ConfigItemMapNamed:
    """Create an element from a dictionary.

    Args:
        data: The ConfigItemMapNamed content serialized as a dict.

    Returns:
        A ConfigItemMapNamed.
    """
    return cast(ConfigItemMapNamed, _from_dict(data))

ConfigItemSet

Bases: Element

Represents a container element for application setting elements, “config:config-item-set” tag.

This element can contain other configuration items, item maps, or item sets, forming a hierarchical structure for document settings.

Attributes:

Name Type Description
name str

The name of the configuration item set.

Methods:

Name Description
__init__

Initialize a ConfigItemSet element.

__repr__
as_dict

Serialize the element to a dictionary.

from_dict

Create an element from a dictionary.

Source code in odfdo/config_elements.py
 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
class ConfigItemSet(Element):
    """Represents a container element for application setting elements,
    "config:config-item-set" tag.

    This element can contain other configuration items, item maps, or item
    sets, forming a hierarchical structure for document settings.

    Attributes:
        name (str): The name of the configuration item set.
    """

    _tag: str = "config:config-item-set"
    _properties: tuple[PropDef | PropDefBool, ...] = (PropDef("name", "config:name"),)

    def __init__(
        self,
        name: str | None = None,
        **kwargs: Any,
    ) -> None:
        """Initialize a ConfigItemSet element.

        This element acts as a container for various application setting
        elements, including `config:config-item`,
        `config:config-item-map-indexed`, `config:config-item-map-named`,
        and nested `config:config-item-set`.

        The "config:config-item-set" element has the following child elements:
        "config:config-item", "config:config-item-map-indexed",
        "config:config-item-map-named" and "config:config-item-set"

        Args:
            name: The name of the configuration item set.
        """
        super().__init__(**kwargs)
        if self._do_init:
            self.name = name

    def __repr__(self) -> str:
        return f"<{self.__class__.__name__} tag={self.tag} name={self.name}>"

    @property
    def config_item_sets(self) -> list[ConfigItemSet]:
        """Get the list of nested ConfigItemSet elements.

        Returns:
            list[ConfigItemSet]: A list of `ConfigItemSet` objects.
        """
        return cast(list[ConfigItemSet], self.get_elements("config:config-item-set"))

    @property
    def config_item_maps_indexed(self) -> list[ConfigItemMapIndexed]:
        """Get the list of indexed configuration item maps.

        Returns:
            list[ConfigItemMapIndexed]: A list of `ConfigItemMapIndexed`
                objects.
        """
        return cast(
            list[ConfigItemMapIndexed],
            self.get_elements("config:config-item-map-indexed"),
        )

    @property
    def config_item_maps_named(self) -> list[ConfigItemMapNamed]:
        """Get the list of named configuration item maps.

        Returns:
            list[ConfigItemMapNamed]: A list of `ConfigItemMapNamed` objects.
        """
        return cast(
            list[ConfigItemMapNamed], self.get_elements("config:config-item-map-named")
        )

    @property
    def config_items(self) -> list[ConfigItem]:
        """Get the list of individual configuration items.

        Returns:
            list[ConfigItem]: A list of `ConfigItem` objects.
        """
        return cast(list[ConfigItem], self.get_elements("config:config-item"))

    def as_dict(self) -> dict[str, str | int | bool | list[Any] | dict[str, Any]]:
        """Serialize the element to a dictionary.

        Returns:
            A dict with content of the ConfigItemSet serialized.
        """
        return _as_dict(self)

    @classmethod
    def from_dict(
        cls, data: dict[str, str | int | bool | dict[str, Any]]
    ) -> ConfigItemSet:
        """Create an element from a dictionary.

        Args:
            data: The ConfigItemSet content serialized as a dict.

        Returns:
            A ConfigItemSet.
        """
        return cast(ConfigItemSet, _from_dict(data))

_properties class-attribute instance-attribute

_properties: tuple[PropDef | PropDefBool, ...] = (
    PropDef("name", "config:name"),
)

_tag class-attribute instance-attribute

_tag: str = 'config:config-item-set'

config_item_maps_indexed property

config_item_maps_indexed: list[ConfigItemMapIndexed]

Get the list of indexed configuration item maps.

Returns:

Type Description
list[ConfigItemMapIndexed]

list[ConfigItemMapIndexed]: A list of ConfigItemMapIndexed objects.

config_item_maps_named property

config_item_maps_named: list[ConfigItemMapNamed]

Get the list of named configuration item maps.

Returns:

Type Description
list[ConfigItemMapNamed]

list[ConfigItemMapNamed]: A list of ConfigItemMapNamed objects.

config_item_sets property

config_item_sets: list[ConfigItemSet]

Get the list of nested ConfigItemSet elements.

Returns:

Type Description
list[ConfigItemSet]

list[ConfigItemSet]: A list of ConfigItemSet objects.

config_items property

config_items: list[ConfigItem]

Get the list of individual configuration items.

Returns:

Type Description
list[ConfigItem]

list[ConfigItem]: A list of ConfigItem objects.

name instance-attribute

name = name

__init__

__init__(name: str | None = None, **kwargs: Any) -> None

Initialize a ConfigItemSet element.

This element acts as a container for various application setting elements, including config:config-item, config:config-item-map-indexed, config:config-item-map-named, and nested config:config-item-set.

The “config:config-item-set” element has the following child elements: “config:config-item”, “config:config-item-map-indexed”, “config:config-item-map-named” and “config:config-item-set”

Parameters:

Name Type Description Default
name str | None

The name of the configuration item set.

None
Source code in odfdo/config_elements.py
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
def __init__(
    self,
    name: str | None = None,
    **kwargs: Any,
) -> None:
    """Initialize a ConfigItemSet element.

    This element acts as a container for various application setting
    elements, including `config:config-item`,
    `config:config-item-map-indexed`, `config:config-item-map-named`,
    and nested `config:config-item-set`.

    The "config:config-item-set" element has the following child elements:
    "config:config-item", "config:config-item-map-indexed",
    "config:config-item-map-named" and "config:config-item-set"

    Args:
        name: The name of the configuration item set.
    """
    super().__init__(**kwargs)
    if self._do_init:
        self.name = name

__repr__

__repr__() -> str
Source code in odfdo/config_elements.py
115
116
def __repr__(self) -> str:
    return f"<{self.__class__.__name__} tag={self.tag} name={self.name}>"

as_dict

as_dict() -> dict[
    str, str | int | bool | list[Any] | dict[str, Any]
]

Serialize the element to a dictionary.

Returns:

Type Description
dict[str, str | int | bool | list[Any] | dict[str, Any]]

A dict with content of the ConfigItemSet serialized.

Source code in odfdo/config_elements.py
160
161
162
163
164
165
166
def as_dict(self) -> dict[str, str | int | bool | list[Any] | dict[str, Any]]:
    """Serialize the element to a dictionary.

    Returns:
        A dict with content of the ConfigItemSet serialized.
    """
    return _as_dict(self)

from_dict classmethod

from_dict(
    data: dict[str, str | int | bool | dict[str, Any]],
) -> ConfigItemSet

Create an element from a dictionary.

Parameters:

Name Type Description Default
data dict[str, str | int | bool | dict[str, Any]]

The ConfigItemSet content serialized as a dict.

required

Returns:

Type Description
ConfigItemSet

A ConfigItemSet.

Source code in odfdo/config_elements.py
168
169
170
171
172
173
174
175
176
177
178
179
180
@classmethod
def from_dict(
    cls, data: dict[str, str | int | bool | dict[str, Any]]
) -> ConfigItemSet:
    """Create an element from a dictionary.

    Args:
        data: The ConfigItemSet content serialized as a dict.

    Returns:
        A ConfigItemSet.
    """
    return cast(ConfigItemSet, _from_dict(data))

_as_dict

_as_dict(
    element: ConfigItemMapEntry
    | ConfigItemMapIndexed
    | ConfigItemMapNamed
    | ConfigItemSet,
) -> dict[
    str, str | int | bool | list[Any] | dict[str, Any]
]

Internal helper to serialize a configuration element to a dictionary.

Source code in odfdo/config_elements.py
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
def _as_dict(
    element: ConfigItemMapEntry
    | ConfigItemMapIndexed
    | ConfigItemMapNamed
    | ConfigItemSet,
) -> dict[str, str | int | bool | list[Any] | dict[str, Any]]:
    """Internal helper to serialize a configuration element to a dictionary."""
    conf: dict[str, str | int | bool | list[Any] | dict[str, Any]] = {
        "class": element._tag
    }
    if element.name:
        conf["config:name"] = element.name
    # all children are known to be classes with as_dict()
    children = [child.as_dict() for child in element.children]  # type: ignore[attr-defined]
    if children:
        conf["children"] = children
    return conf

_from_dict

_from_dict(
    data: dict[str, str | int | bool | dict[str, Any]],
) -> Element

Internal helper to deserialize a dictionary into a configuration element.

Source code in odfdo/config_elements.py
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
def _from_dict(data: dict[str, str | int | bool | dict[str, Any]]) -> Element:
    """Internal helper to deserialize a dictionary into a configuration
    element.
    """
    class_tag: str = data.pop("class")  # type: ignore[assignment]
    if class_tag == "config:config-item":
        return ConfigItem.from_dict(data)  # type: ignore[arg-type]
    kwargs: dict[str, str | int | bool] = {}
    if "config:name" in data:
        kwargs["name"] = data.pop("config:name")  # type: ignore[assignment]
    children: list[Any] = data.pop("children", [])  # type: ignore[assignment]
    klass = class_from_tag(class_tag)
    result = klass(**kwargs)
    for child in children:
        result.append(_from_dict(child))
    return result