From c21b93b0be4efd1726782800449488150610533f Mon Sep 17 00:00:00 2001 From: Steve Canny Date: Tue, 6 Aug 2024 13:16:25 -0700 Subject: [PATCH] fix(enum): replace read-only enum values Some enum values like `MSO_SHAPE_TYPE.MIXED` are never produced by `python-pptx` and so were removed during the enum modernization in commit `01b86e64`. However, in at least one downstream system these values are referenced even though they can never actually occur. Replace these "read-only" values to avoid downstream breakage. --- src/pptx/enum/chart.py | 7 +++++-- src/pptx/enum/dml.py | 12 ++++++++---- src/pptx/enum/lang.py | 3 +++ src/pptx/enum/shapes.py | 28 ++++++++++++++++++++++------ src/pptx/enum/text.py | 12 ++++++++++++ 5 files changed, 50 insertions(+), 12 deletions(-) diff --git a/src/pptx/enum/chart.py b/src/pptx/enum/chart.py index 5e609ebd..2599cf4d 100644 --- a/src/pptx/enum/chart.py +++ b/src/pptx/enum/chart.py @@ -335,6 +335,9 @@ class XL_DATA_LABEL_POSITION(BaseXmlEnum): LEFT = (-4131, "l", "The data label is positioned to the left of the data point.") """The data label is positioned to the left of the data point.""" + MIXED = (6, "", "Data labels are in multiple positions (read-only).") + """Data labels are in multiple positions (read-only).""" + OUTSIDE_END = ( 2, "outEnd", @@ -370,8 +373,8 @@ class XL_LEGEND_POSITION(BaseXmlEnum): CORNER = (2, "tr", "In the upper-right corner of the chart border.") """In the upper-right corner of the chart border.""" - CUSTOM = (-4161, "", "A custom position.") - """A custom position.""" + CUSTOM = (-4161, "", "A custom position (read-only).") + """A custom position (read-only).""" LEFT = (-4131, "l", "Left of the chart.") """Left of the chart.""" diff --git a/src/pptx/enum/dml.py b/src/pptx/enum/dml.py index e9a14b13..40d5c5cd 100644 --- a/src/pptx/enum/dml.py +++ b/src/pptx/enum/dml.py @@ -319,8 +319,8 @@ class MSO_PATTERN_TYPE(BaseXmlEnum): ZIG_ZAG = (38, "zigZag", "Zig Zag") """Zig Zag""" - MIXED = (-2, "", "Mixed pattern") - """Mixed pattern""" + MIXED = (-2, "", "Mixed pattern (read-only).") + """Mixed pattern (read-only).""" MSO_PATTERN = MSO_PATTERN_TYPE @@ -394,8 +394,12 @@ class MSO_THEME_COLOR_INDEX(BaseXmlEnum): TEXT_2 = (15, "tx2", "Specifies the Text 2 theme color.") """Specifies the Text 2 theme color.""" - MIXED = (-2, "", "Indicates multiple theme colors are used, such as in a group shape.") - """Indicates multiple theme colors are used, such as in a group shape.""" + MIXED = ( + -2, + "", + "Indicates multiple theme colors are used, such as in a group shape (read-only).", + ) + """Indicates multiple theme colors are used, such as in a group shape (read-only).""" MSO_THEME_COLOR = MSO_THEME_COLOR_INDEX diff --git a/src/pptx/enum/lang.py b/src/pptx/enum/lang.py index d2da5b6a..a6bc1c8b 100644 --- a/src/pptx/enum/lang.py +++ b/src/pptx/enum/lang.py @@ -680,3 +680,6 @@ class MSO_LANGUAGE_ID(BaseXmlEnum): ZULU = (1077, "zu-ZA", "The Zulu language.") """The Zulu language.""" + + MIXED = (-2, "", "More than one language in specified range (read-only).") + """More than one language in specified range (read-only).""" diff --git a/src/pptx/enum/shapes.py b/src/pptx/enum/shapes.py index b1dec8ad..86f521f4 100644 --- a/src/pptx/enum/shapes.py +++ b/src/pptx/enum/shapes.py @@ -748,6 +748,9 @@ class MSO_CONNECTOR_TYPE(BaseXmlEnum): STRAIGHT = (1, "line", "Straight line connector.") """Straight line connector.""" + MIXED = (-2, "", "Return value only; indicates a combination of other states.") + """Return value only; indicates a combination of other states.""" + MSO_CONNECTOR = MSO_CONNECTOR_TYPE @@ -843,6 +846,9 @@ class MSO_SHAPE_TYPE(BaseEnum): WEB_VIDEO = (26, "Web video") """Web video""" + MIXED = (-2, "Multiple shape types (read-only).") + """Multiple shape types (read-only).""" + MSO = MSO_SHAPE_TYPE @@ -871,6 +877,16 @@ class PP_MEDIA_TYPE(BaseEnum): SOUND = (1, "Audio media such as MP3.") """Audio media such as MP3.""" + MIXED = ( + -2, + "Return value only; indicates multiple media types, typically for a collection of shapes." + " May not be applicable in python-pptx.", + ) + """Return value only; indicates multiple media types. + + Typically for a collection of shapes. May not be applicable in python-pptx. + """ + class PP_PLACEHOLDER_TYPE(BaseXmlEnum): """Specifies one of the 18 distinct types of placeholder. @@ -937,14 +953,14 @@ class PP_PLACEHOLDER_TYPE(BaseXmlEnum): TITLE = (1, "title", "Title") """Title""" - VERTICAL_BODY = (6, "", "Vertical Body") - """Vertical Body""" + VERTICAL_BODY = (6, "", "Vertical Body (read-only).") + """Vertical Body (read-only).""" - VERTICAL_OBJECT = (17, "", "Vertical Object") - """Vertical Object""" + VERTICAL_OBJECT = (17, "", "Vertical Object (read-only).") + """Vertical Object (read-only).""" - VERTICAL_TITLE = (5, "", "Vertical Title") - """Vertical Title""" + VERTICAL_TITLE = (5, "", "Vertical Title (read-only).") + """Vertical Title (read-only).""" MIXED = (-2, "", "Return value only; multiple placeholders of differing types.") """Return value only; multiple placeholders of differing types.""" diff --git a/src/pptx/enum/text.py b/src/pptx/enum/text.py index 89238515..db266a3c 100644 --- a/src/pptx/enum/text.py +++ b/src/pptx/enum/text.py @@ -57,6 +57,9 @@ class MSO_AUTO_SIZE(BaseEnum): ) """The font size is reduced as necessary to fit the text within the shape.""" + MIXED = (-2, "Return value only; indicates a combination of automatic sizing schemes are used.") + """Return value only; indicates a combination of automatic sizing schemes are used.""" + class MSO_TEXT_UNDERLINE_TYPE(BaseXmlEnum): """ @@ -134,6 +137,9 @@ class MSO_TEXT_UNDERLINE_TYPE(BaseXmlEnum): WORDS = (1, "words", "Specifies underlining words.") """Specifies underlining words.""" + MIXED = (-2, "", "Specifies a mix of underline types (read-only).") + """Specifies a mix of underline types (read-only).""" + MSO_UNDERLINE = MSO_TEXT_UNDERLINE_TYPE @@ -161,6 +167,9 @@ class MSO_VERTICAL_ANCHOR(BaseXmlEnum): BOTTOM = (4, "b", "Aligns text to bottom of text frame") """Aligns text to bottom of text frame""" + MIXED = (-2, "", "Return value only; indicates a combination of the other states.") + """Return value only; indicates a combination of the other states.""" + MSO_ANCHOR = MSO_VERTICAL_ANCHOR @@ -214,5 +223,8 @@ class PP_PARAGRAPH_ALIGNMENT(BaseXmlEnum): THAI_DISTRIBUTE = (6, "thaiDist", "Thai distributed") """Thai distributed""" + MIXED = (-2, "", "Multiple alignments are present in a set of paragraphs (read-only).") + """Multiple alignments are present in a set of paragraphs (read-only).""" + PP_ALIGN = PP_PARAGRAPH_ALIGNMENT