microsoft/hve-core

Public

mirrored from https://github.com/microsoft/hve-coreAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
fix/1124-exclude-python-env-dirs-from-skill-validation

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.github/skills/experimental/powerpoint/scripts/pptx_shapes.py

64lines · modecode

1# Copyright (c) Microsoft Corporation.
2# SPDX-License-Identifier: MIT
3"""Shape constants, maps, and rotation utilities for PowerPoint skill scripts.
4
5Provides the expanded SHAPE_MAP (30+ entries), an inverse AUTO_SHAPE_NAME_MAP
6for extraction, and rotation helper functions.
7"""
8
9from pptx.enum.shapes import MSO_SHAPE
10
11SHAPE_MAP = {
12 # Original 9
13 "rectangle": MSO_SHAPE.RECTANGLE,
14 "rounded_rectangle": MSO_SHAPE.ROUNDED_RECTANGLE,
15 "right_arrow": MSO_SHAPE.RIGHT_ARROW,
16 "chevron": MSO_SHAPE.CHEVRON,
17 "oval": MSO_SHAPE.OVAL,
18 "diamond": MSO_SHAPE.DIAMOND,
19 "pentagon": MSO_SHAPE.PENTAGON,
20 "hexagon": MSO_SHAPE.HEXAGON,
21 "right_triangle": MSO_SHAPE.RIGHT_TRIANGLE,
22 # Arrows
23 "left_arrow": MSO_SHAPE.LEFT_ARROW,
24 "up_arrow": MSO_SHAPE.UP_ARROW,
25 "down_arrow": MSO_SHAPE.DOWN_ARROW,
26 "left_right_arrow": MSO_SHAPE.LEFT_RIGHT_ARROW,
27 "notched_right_arrow": MSO_SHAPE.NOTCHED_RIGHT_ARROW,
28 # Flowchart
29 "flowchart_process": MSO_SHAPE.FLOWCHART_PROCESS,
30 "flowchart_decision": MSO_SHAPE.FLOWCHART_DECISION,
31 "flowchart_terminator": MSO_SHAPE.FLOWCHART_TERMINATOR,
32 "flowchart_data": MSO_SHAPE.FLOWCHART_DATA,
33 # Common shapes
34 "cross": MSO_SHAPE.CROSS,
35 "donut": MSO_SHAPE.DONUT,
36 "star_5_point": MSO_SHAPE.STAR_5_POINT,
37 "cloud": MSO_SHAPE.CLOUD,
38 "trapezoid": MSO_SHAPE.TRAPEZOID,
39 "parallelogram": MSO_SHAPE.PARALLELOGRAM,
40 "left_brace": MSO_SHAPE.LEFT_BRACE,
41 "right_brace": MSO_SHAPE.RIGHT_BRACE,
42 "callout_rectangle": MSO_SHAPE.RECTANGULAR_CALLOUT,
43 "callout_rounded_rectangle": MSO_SHAPE.ROUNDED_RECTANGULAR_CALLOUT,
44 # Alias
45 "circle": MSO_SHAPE.OVAL,
46}
47
48# Inverse map: MSO_AUTO_SHAPE_TYPE enum value -> YAML shape name
49# Excludes "circle" alias so "oval" is the canonical name for MSO_SHAPE.OVAL
50AUTO_SHAPE_NAME_MAP = {v: k for k, v in SHAPE_MAP.items() if k != "circle"}
51
52
53def apply_rotation(shape, rotation: float | None):
54 """Apply rotation in degrees to a shape when specified."""
55 if rotation is not None and rotation != 0:
56 shape.rotation = rotation
57
58
59def extract_rotation(shape) -> float | None:
60 """Extract rotation in degrees, returning None when zero."""
61 rot = shape.rotation
62 if rot and rot != 0.0:
63 return rot
64 return None
65