init: 폴더구조 설계 및 인프라 설계

This commit is contained in:
DongHyeonka
2026-07-24 14:31:53 +09:00
parent 34ad612281
commit f9c463f87a
1839 changed files with 323096 additions and 1 deletions
@@ -0,0 +1,111 @@
"""lxml custom element classes for DrawingML-related XML elements."""
from __future__ import annotations
from pptx.enum.dml import MSO_THEME_COLOR
from pptx.oxml.simpletypes import ST_HexColorRGB, ST_Percentage
from pptx.oxml.xmlchemy import (
BaseOxmlElement,
Choice,
RequiredAttribute,
ZeroOrOne,
ZeroOrOneChoice,
)
class _BaseColorElement(BaseOxmlElement):
"""
Base class for <a:srgbClr> and <a:schemeClr> elements.
"""
lumMod = ZeroOrOne("a:lumMod")
lumOff = ZeroOrOne("a:lumOff")
def add_lumMod(self, value):
"""
Return a newly added <a:lumMod> child element.
"""
lumMod = self._add_lumMod()
lumMod.val = value
return lumMod
def add_lumOff(self, value):
"""
Return a newly added <a:lumOff> child element.
"""
lumOff = self._add_lumOff()
lumOff.val = value
return lumOff
def clear_lum(self):
"""
Return self after removing any <a:lumMod> and <a:lumOff> child
elements.
"""
self._remove_lumMod()
self._remove_lumOff()
return self
class CT_Color(BaseOxmlElement):
"""Custom element class for `a:fgClr`, `a:bgClr` and perhaps others."""
eg_colorChoice = ZeroOrOneChoice(
(
Choice("a:scrgbClr"),
Choice("a:srgbClr"),
Choice("a:hslClr"),
Choice("a:sysClr"),
Choice("a:schemeClr"),
Choice("a:prstClr"),
),
successors=(),
)
class CT_HslColor(_BaseColorElement):
"""
Custom element class for <a:hslClr> element.
"""
class CT_Percentage(BaseOxmlElement):
"""
Custom element class for <a:lumMod> and <a:lumOff> elements.
"""
val = RequiredAttribute("val", ST_Percentage)
class CT_PresetColor(_BaseColorElement):
"""
Custom element class for <a:prstClr> element.
"""
class CT_SchemeColor(_BaseColorElement):
"""
Custom element class for <a:schemeClr> element.
"""
val = RequiredAttribute("val", MSO_THEME_COLOR)
class CT_ScRgbColor(_BaseColorElement):
"""
Custom element class for <a:scrgbClr> element.
"""
class CT_SRgbColor(_BaseColorElement):
"""
Custom element class for <a:srgbClr> element.
"""
val = RequiredAttribute("val", ST_HexColorRGB)
class CT_SystemColor(_BaseColorElement):
"""
Custom element class for <a:sysClr> element.
"""
@@ -0,0 +1,197 @@
"""lxml custom element classes for DrawingML-related XML elements."""
from __future__ import annotations
from pptx.enum.dml import MSO_PATTERN_TYPE
from pptx.oxml import parse_xml
from pptx.oxml.ns import nsdecls
from pptx.oxml.simpletypes import (
ST_Percentage,
ST_PositiveFixedAngle,
ST_PositiveFixedPercentage,
ST_RelationshipId,
)
from pptx.oxml.xmlchemy import (
BaseOxmlElement,
Choice,
OneOrMore,
OptionalAttribute,
RequiredAttribute,
ZeroOrOne,
ZeroOrOneChoice,
)
class CT_Blip(BaseOxmlElement):
"""
<a:blip> element
"""
rEmbed = OptionalAttribute("r:embed", ST_RelationshipId)
class CT_BlipFillProperties(BaseOxmlElement):
"""
Custom element class for <a:blipFill> element.
"""
_tag_seq = ("a:blip", "a:srcRect", "a:tile", "a:stretch")
blip = ZeroOrOne("a:blip", successors=_tag_seq[1:])
srcRect = ZeroOrOne("a:srcRect", successors=_tag_seq[2:])
del _tag_seq
def crop(self, cropping):
"""
Set `a:srcRect` child to crop according to *cropping* values.
"""
srcRect = self._add_srcRect()
srcRect.l, srcRect.t, srcRect.r, srcRect.b = cropping
class CT_GradientFillProperties(BaseOxmlElement):
"""`a:gradFill` custom element class."""
_tag_seq = ("a:gsLst", "a:lin", "a:path", "a:tileRect")
gsLst = ZeroOrOne("a:gsLst", successors=_tag_seq[1:])
lin = ZeroOrOne("a:lin", successors=_tag_seq[2:])
path = ZeroOrOne("a:path", successors=_tag_seq[3:])
del _tag_seq
@classmethod
def new_gradFill(cls):
"""Return newly-created "loose" default gradient subtree."""
return parse_xml(
'<a:gradFill %s rotWithShape="1">\n'
" <a:gsLst>\n"
' <a:gs pos="0">\n'
' <a:schemeClr val="accent1">\n'
' <a:tint val="100000"/>\n'
' <a:shade val="100000"/>\n'
' <a:satMod val="130000"/>\n'
" </a:schemeClr>\n"
" </a:gs>\n"
' <a:gs pos="100000">\n'
' <a:schemeClr val="accent1">\n'
' <a:tint val="50000"/>\n'
' <a:shade val="100000"/>\n'
' <a:satMod val="350000"/>\n'
" </a:schemeClr>\n"
" </a:gs>\n"
" </a:gsLst>\n"
' <a:lin scaled="0"/>\n'
"</a:gradFill>\n" % nsdecls("a")
)
def _new_gsLst(self):
"""Override default to add minimum subtree."""
return CT_GradientStopList.new_gsLst()
class CT_GradientStop(BaseOxmlElement):
"""`a:gs` custom element class."""
eg_colorChoice = ZeroOrOneChoice(
(
Choice("a:scrgbClr"),
Choice("a:srgbClr"),
Choice("a:hslClr"),
Choice("a:sysClr"),
Choice("a:schemeClr"),
Choice("a:prstClr"),
),
successors=(),
)
pos = RequiredAttribute("pos", ST_PositiveFixedPercentage)
class CT_GradientStopList(BaseOxmlElement):
"""`a:gsLst` custom element class."""
gs = OneOrMore("a:gs")
@classmethod
def new_gsLst(cls):
"""Return newly-created "loose" default stop-list subtree.
An `a:gsLst` element must have at least two `a:gs` children. These
are the default from the PowerPoint built-in "White" template.
"""
return parse_xml(
"<a:gsLst %s>\n"
' <a:gs pos="0">\n'
' <a:schemeClr val="accent1">\n'
' <a:tint val="100000"/>\n'
' <a:shade val="100000"/>\n'
' <a:satMod val="130000"/>\n'
" </a:schemeClr>\n"
" </a:gs>\n"
' <a:gs pos="100000">\n'
' <a:schemeClr val="accent1">\n'
' <a:tint val="50000"/>\n'
' <a:shade val="100000"/>\n'
' <a:satMod val="350000"/>\n'
" </a:schemeClr>\n"
" </a:gs>\n"
"</a:gsLst>\n" % nsdecls("a")
)
class CT_GroupFillProperties(BaseOxmlElement):
"""`a:grpFill` custom element class"""
class CT_LinearShadeProperties(BaseOxmlElement):
"""`a:lin` custom element class"""
ang = OptionalAttribute("ang", ST_PositiveFixedAngle)
class CT_NoFillProperties(BaseOxmlElement):
"""`a:noFill` custom element class"""
class CT_PatternFillProperties(BaseOxmlElement):
"""`a:pattFill` custom element class"""
_tag_seq = ("a:fgClr", "a:bgClr")
fgClr = ZeroOrOne("a:fgClr", successors=_tag_seq[1:])
bgClr = ZeroOrOne("a:bgClr", successors=_tag_seq[2:])
del _tag_seq
prst = OptionalAttribute("prst", MSO_PATTERN_TYPE)
def _new_bgClr(self):
"""Override default to add minimum subtree."""
xml = ("<a:bgClr %s>\n" ' <a:srgbClr val="FFFFFF"/>\n' "</a:bgClr>\n") % nsdecls("a")
bgClr = parse_xml(xml)
return bgClr
def _new_fgClr(self):
"""Override default to add minimum subtree."""
xml = ("<a:fgClr %s>\n" ' <a:srgbClr val="000000"/>\n' "</a:fgClr>\n") % nsdecls("a")
fgClr = parse_xml(xml)
return fgClr
class CT_RelativeRect(BaseOxmlElement):
"""`a:srcRect` element and perhaps others."""
l = OptionalAttribute("l", ST_Percentage, default=0.0) # noqa
t = OptionalAttribute("t", ST_Percentage, default=0.0)
r = OptionalAttribute("r", ST_Percentage, default=0.0)
b = OptionalAttribute("b", ST_Percentage, default=0.0)
class CT_SolidColorFillProperties(BaseOxmlElement):
"""`a:solidFill` custom element class."""
eg_colorChoice = ZeroOrOneChoice(
(
Choice("a:scrgbClr"),
Choice("a:srgbClr"),
Choice("a:hslClr"),
Choice("a:sysClr"),
Choice("a:schemeClr"),
Choice("a:prstClr"),
),
successors=(),
)
@@ -0,0 +1,12 @@
"""lxml custom element classes for DrawingML line-related XML elements."""
from __future__ import annotations
from pptx.enum.dml import MSO_LINE_DASH_STYLE
from pptx.oxml.xmlchemy import BaseOxmlElement, OptionalAttribute
class CT_PresetLineDashProperties(BaseOxmlElement):
"""`a:prstDash` custom element class"""
val = OptionalAttribute("val", MSO_LINE_DASH_STYLE)