Rename Stylesheet to StyleSheet
And stylesheet to styleSheet.
This commit is contained in:
parent
c31c855566
commit
b26aa0836c
@ -1509,5 +1509,5 @@
|
||||
<val>val</val>
|
||||
</name>
|
||||
</Property>
|
||||
<Stylesheet id="3b6a9420-9fe2-11ea-b537-dfaaecc5bf61"/>
|
||||
<StyleSheet id="3b6a9420-9fe2-11ea-b537-dfaaecc5bf61"/>
|
||||
</gaphor>
|
@ -16,7 +16,7 @@ from gaphor.core.modeling import (
|
||||
Element,
|
||||
NamedElement,
|
||||
PackageableElement,
|
||||
Stylesheet,
|
||||
StyleSheet,
|
||||
)
|
||||
from gaphor.core.modeling.properties import (
|
||||
association,
|
||||
|
@ -7,4 +7,4 @@ from gaphor.core.modeling.coremodel import (
|
||||
from gaphor.core.modeling.diagram import Diagram
|
||||
from gaphor.core.modeling.elementfactory import ElementFactory
|
||||
from gaphor.core.modeling.event import *
|
||||
from gaphor.core.modeling.presentation import Presentation, Stylesheet
|
||||
from gaphor.core.modeling.presentation import Presentation, StyleSheet
|
||||
|
@ -50,13 +50,13 @@ class Comment(Element):
|
||||
annotatedElement: relation_many[Element]
|
||||
|
||||
|
||||
# 40: override Stylesheet
|
||||
# 40: override StyleSheet
|
||||
# defined in gaphor.core.modeling.presentation
|
||||
|
||||
|
||||
NamedElement.name = attribute("name", str)
|
||||
Comment.body = attribute("body", str)
|
||||
# 43: override Stylesheet.stylesheet
|
||||
# 43: override StyleSheet.styleSheet
|
||||
# defined in gaphor.core.modeling.presentation
|
||||
|
||||
# 52: override Presentation.subject
|
||||
|
@ -26,7 +26,7 @@ def read_style_py():
|
||||
import os.path
|
||||
import ast
|
||||
|
||||
sheet_py = os.path.join(get_config_dir(), "stylesheet.py")
|
||||
sheet_py = os.path.join(get_config_dir(), "styleSheet.py")
|
||||
try:
|
||||
with open(sheet_py) as f:
|
||||
return ast.literal_eval(f.read())
|
||||
@ -34,12 +34,12 @@ def read_style_py():
|
||||
return {}
|
||||
|
||||
|
||||
class Stylesheet(Element):
|
||||
class StyleSheet(Element):
|
||||
def __init__(self, id=None, model=None):
|
||||
super().__init__(id, model)
|
||||
self._style = read_style_py()
|
||||
|
||||
stylesheet: attribute[str] = attribute("stylesheet", str)
|
||||
styleSheet: attribute[str] = attribute("styleSheet", str)
|
||||
|
||||
def item_style(self, item):
|
||||
return self._style
|
||||
@ -65,12 +65,12 @@ class Presentation(Element, Generic[S]):
|
||||
)
|
||||
|
||||
@property
|
||||
def stylesheet(self) -> Optional[Stylesheet]:
|
||||
return next(self.model.select(Stylesheet), None,) # type: ignore[arg-type]
|
||||
def styleSheet(self) -> Optional[StyleSheet]:
|
||||
return next(self.model.select(StyleSheet), None,) # type: ignore[arg-type]
|
||||
|
||||
@property
|
||||
def style(self):
|
||||
sheet = self.stylesheet
|
||||
sheet = self.styleSheet
|
||||
return sheet and sheet.item_style(self) or {}
|
||||
|
||||
handles: Callable[[Presentation], List[Handle]]
|
||||
|
@ -4,7 +4,7 @@ from gaphas.item import Item
|
||||
from gaphor.core.eventmanager import EventManager
|
||||
from gaphor.core.modeling.diagram import Diagram
|
||||
from gaphor.core.modeling.elementfactory import ElementFactory
|
||||
from gaphor.core.modeling.presentation import Presentation, Stylesheet
|
||||
from gaphor.core.modeling.presentation import Presentation, StyleSheet
|
||||
|
||||
|
||||
class StubItem(Presentation, Item):
|
||||
@ -23,13 +23,13 @@ def diagram(element_factory):
|
||||
|
||||
|
||||
def test_presentation_stylesheet(diagram, element_factory):
|
||||
stylesheet = element_factory.create(Stylesheet)
|
||||
styleSheet = element_factory.create(StyleSheet)
|
||||
presentation = diagram.create(StubItem)
|
||||
|
||||
assert presentation.stylesheet is stylesheet
|
||||
assert presentation.styleSheet is styleSheet
|
||||
|
||||
|
||||
def test_presentation_stylesheet_is_absent(diagram):
|
||||
presentation = diagram.create(StubItem)
|
||||
|
||||
assert presentation.stylesheet is None
|
||||
assert presentation.styleSheet is None
|
||||
|
@ -10,7 +10,7 @@ from gaphas.item import NW, Element
|
||||
from gaphas.item import Line as _Line
|
||||
from gaphas.util import path_ellipse
|
||||
|
||||
from gaphor.core.modeling import Presentation, Stylesheet
|
||||
from gaphor.core.modeling import Presentation
|
||||
from gaphor.diagram.shapes import DrawContext, combined_style, stroke
|
||||
|
||||
|
||||
|
@ -87,7 +87,7 @@
|
||||
<val>(1.0, 0.0, 0.0, 1.0, 174.91839599609347, 521.4187622070312)</val>
|
||||
</matrix>
|
||||
<width>
|
||||
<val>184.0</val>
|
||||
<val>186.0</val>
|
||||
</width>
|
||||
<height>
|
||||
<val>66.0</val>
|
||||
@ -231,7 +231,7 @@
|
||||
<val>0</val>
|
||||
</horizontal>
|
||||
<points>
|
||||
<val>[(0.0, 0.0), (0.0, 74.77569580078125), (-312.4324951171878, 74.77569580078125), (-312.4324951171878, 400.1944580078125)]</val>
|
||||
<val>[(0.0, 0.0), (0.0, 74.77569580078125), (-311.43589451002066, 74.77569580078125), (-311.43589451002066, 400.1944580078125)]</val>
|
||||
</points>
|
||||
<head-connection>
|
||||
<ref refid="4cda498f-7a95-11ea-a112-7f953848cf85"/>
|
||||
@ -371,7 +371,7 @@
|
||||
<val>(1.0, 0.0, 0.0, 1.0, 405.7207298415308, 523.8687744140625)</val>
|
||||
</matrix>
|
||||
<width>
|
||||
<val>147.0</val>
|
||||
<val>149.0</val>
|
||||
</width>
|
||||
<height>
|
||||
<val>66.0</val>
|
||||
@ -397,7 +397,7 @@
|
||||
<val>0</val>
|
||||
</horizontal>
|
||||
<points>
|
||||
<val>[(0.0, 0.0), (0.0, 74.77569580078125), (-99.67199572428763, 74.77569580078125), (-99.67199572428763, 402.64447021484375)]</val>
|
||||
<val>[(0.0, 0.0), (0.0, 74.77569580078125), (-98.67207745885685, 74.77569580078125), (-98.67207745885685, 402.64447021484375)]</val>
|
||||
</points>
|
||||
<head-connection>
|
||||
<ref refid="4cda498f-7a95-11ea-a112-7f953848cf85"/>
|
||||
@ -422,7 +422,7 @@
|
||||
</item>
|
||||
<item id="ada170c7-9f17-11ea-b537-dfaaecc5bf61" type="CommentLineItem">
|
||||
<matrix>
|
||||
<val>(1.0, 0.0, 0.0, 1.0, 431.7618408203125, 523.8687744140625)</val>
|
||||
<val>(1.0, 0.0, 0.0, 1.0, 432.1161416499558, 523.8687744140625)</val>
|
||||
</matrix>
|
||||
<orthogonal>
|
||||
<val>0</val>
|
||||
@ -431,7 +431,7 @@
|
||||
<val>0</val>
|
||||
</horizontal>
|
||||
<points>
|
||||
<val>[(0.0, 0.0), (-50.89434814453125, -45.74224853515625)]</val>
|
||||
<val>[(0.0, 0.0), (-51.24864897417456, -45.74224853515625)]</val>
|
||||
</points>
|
||||
<head-connection>
|
||||
<ref refid="15e4b0b3-9f17-11ea-b537-dfaaecc5bf61"/>
|
||||
@ -844,10 +844,10 @@
|
||||
<val>1</val>
|
||||
</isDerived>
|
||||
<name>
|
||||
<val>stylesheet</val>
|
||||
<val>styleSheet</val>
|
||||
</name>
|
||||
<typeValue>
|
||||
<val>Stylesheet</val>
|
||||
<val>StyleSheet</val>
|
||||
</typeValue>
|
||||
</Property>
|
||||
<Class id="15e4b0b2-9f17-11ea-b537-dfaaecc5bf61">
|
||||
@ -857,7 +857,7 @@
|
||||
</reflist>
|
||||
</generalization>
|
||||
<name>
|
||||
<val>Stylesheet</val>
|
||||
<val>StyleSheet</val>
|
||||
</name>
|
||||
<ownedAttribute>
|
||||
<reflist>
|
||||
@ -883,7 +883,7 @@
|
||||
<ref refid="15e4b0b2-9f17-11ea-b537-dfaaecc5bf61"/>
|
||||
</class_>
|
||||
<name>
|
||||
<val>stylesheet</val>
|
||||
<val>styleSheet</val>
|
||||
</name>
|
||||
<typeValue>
|
||||
<val>String</val>
|
||||
|
@ -37,10 +37,10 @@ NamedElement.qualifiedName = derived(
|
||||
lambda obj: [_namedelement_qualifiedname(obj)],
|
||||
)
|
||||
%%
|
||||
override Stylesheet
|
||||
override StyleSheet
|
||||
# defined in gaphor.core.modeling.presentation
|
||||
%%
|
||||
override Stylesheet.stylesheet
|
||||
override StyleSheet.styleSheet
|
||||
# defined in gaphor.core.modeling.presentation
|
||||
%%
|
||||
override Presentation
|
||||
|
@ -30,7 +30,7 @@ override PackageableElement
|
||||
from gaphor.core.modeling import PackageableElement
|
||||
%%
|
||||
override Diagram
|
||||
from gaphor.core.modeling import Diagram, Stylesheet
|
||||
from gaphor.core.modeling import Diagram, StyleSheet
|
||||
%%
|
||||
override Transition
|
||||
# Invert order of superclasses to avoid MRO issues
|
||||
|
Loading…
Reference in New Issue
Block a user