MCPcopy Create free account
hub / github.com/scanny/python-pptx / CT_Relationship

Class CT_Relationship

src/pptx/opc/oxml.py:92–120  ·  view source on GitHub ↗

` ` element. Represents a single relationship from a source to a target part.

Source from the content-addressed store, hash-verified

90
91
92class CT_Relationship(BaseOxmlElement):
93 """`<Relationship>` element.
94
95 Represents a single relationship from a source to a target part.
96 """
97
98 rId: str = RequiredAttribute("Id", XsdId) # pyright: ignore[reportAssignmentType]
99 reltype: str = RequiredAttribute("Type", XsdAnyUri) # pyright: ignore[reportAssignmentType]
100 target_ref: str = RequiredAttribute( # pyright: ignore[reportAssignmentType]
101 "Target", XsdAnyUri
102 )
103 targetMode: str = OptionalAttribute( # pyright: ignore[reportAssignmentType]
104 "TargetMode", ST_TargetMode, default=RTM.INTERNAL
105 )
106
107 @classmethod
108 def new(
109 cls, rId: str, reltype: str, target_ref: str, target_mode: str = RTM.INTERNAL
110 ) -> CT_Relationship:
111 """Return a new `<Relationship>` element.
112
113 `target_ref` is either a partname or a URI.
114 """
115 relationship = cast(CT_Relationship, parse_xml(f'<Relationship xmlns="{nsmap["pr"]}"/>'))
116 relationship.rId = rId
117 relationship.reltype = reltype
118 relationship.target_ref = target_ref
119 relationship.targetMode = target_mode
120 return relationship
121
122
123class CT_Relationships(BaseOxmlElement):

Callers

nothing calls this directly

Calls 2

RequiredAttributeClass · 0.90
OptionalAttributeClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…