Skip to content

Configuration Options

NewlineReplacement

Bases: Enum

Options how to deal with \n inside rich text values.

  • NONE: don't modify the rich text (\n will be lost, because it is meaningless in an XML file)
  • PARAGRAPH: replace Start\nEnd with <p>Start</p><p>End</p>
  • LINEBREAK: replace Start\nEnd with Start<br/>End

Examples:

# setting the replacement options for newlines
resource = resource.add_richtext(
    prop_name=":propName",
    value="Start\n\nEnd",
    newline_replacement=xmllib.NewlineReplacement.PARAGRAPH
)
Source code in dsp/dsp-tools/src/dsp_tools/xmllib/models/config_options.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class NewlineReplacement(Enum):
    """
    Options how to deal with `\\n` inside rich text values.

    - `NONE`: don't modify the rich text (`\\n` will be lost, because it is meaningless in an XML file)
    - `PARAGRAPH`: replace `Start\\nEnd` with `<p>Start</p><p>End</p>`
    - `LINEBREAK`: replace `Start\\nEnd` with `Start<br/>End`

    Examples:
        ```python
        # setting the replacement options for newlines
        resource = resource.add_richtext(
            prop_name=":propName",
            value="Start\\n\\nEnd",
            newline_replacement=xmllib.NewlineReplacement.PARAGRAPH
        )
        ```
    """

    NONE = auto()
    PARAGRAPH = auto()
    LINEBREAK = auto()

ResourceAuthorshipDefault

Bases: Enum

Sentinel for the apply_default_resource_authorship parameter of XMLRoot.

The single member PROJECT_DEFAULT (used as xmllib.ResourceAuthorshipDefault.PROJECT_DEFAULT) marks that the project's default_data_authorship should be applied to every resource that does not set its own authorship. Unlike a literal list of authors, this is not resolved during serialisation (xmllib does not know the project's default), but at xmlupload, against the project on the server.

Source code in dsp/dsp-tools/src/dsp_tools/xmllib/models/config_options.py
31
32
33
34
35
36
37
38
39
40
41
class ResourceAuthorshipDefault(Enum):
    """
    Sentinel for the `apply_default_resource_authorship` parameter of `XMLRoot`.

    The single member `PROJECT_DEFAULT` (used as `xmllib.ResourceAuthorshipDefault.PROJECT_DEFAULT`) marks that the
    project's `default_data_authorship` should be applied to every resource that does not set its own
    authorship. Unlike a literal list of authors, this is not resolved during serialisation
    (xmllib does not know the project's default), but at `xmlupload`, against the project on the server.
    """

    PROJECT_DEFAULT = auto()