Skip to content

Commit

Permalink
fixed invalid-name check
Browse files Browse the repository at this point in the history
  • Loading branch information
Santiago Balestrini committed Jul 26, 2021
1 parent c7f836b commit 9047117
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 61 deletions.
1 change: 0 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ max-line-length = 99
disable=attribute-defined-outside-init,
cyclic-import,
fixme,
invalid-name,
missing-class-docstring,
missing-function-docstring,
missing-module-docstring,
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
""" look in setup.cfg """
# pylint: disable=invalid-name
import re
from pathlib import Path

Expand Down
12 changes: 6 additions & 6 deletions src/pymbe/interpretation/interp_playbooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,15 +570,15 @@ def validate_working_data(lpg: SysML2LabeledPropertyGraph) -> bool:
"""
# check that all the elements of the graph are in fact proper model elements
all_non_relations = lpg.nodes
for nr_key, nr in all_non_relations.items():
for id_, non_relation in all_non_relations.items():
try:
nr["@type"]
non_relation["@type"]
except KeyError:
print(f"No type found in {nr}, id = '{nr_key}'")
print(f"No type found in {non_relation}, id = '{id_}'")
return False
except TypeError:
print(f"Expecting dict of model element data, got = {nr}")
if "@id" not in nr:
print(f"No '@id' found in {nr}, id = '{nr_key}'")
print(f"Expecting dict of model element data, got = {non_relation}")
if "@id" not in non_relation:
print(f"No '@id' found in {non_relation}, id = '{id_}'")
return False
return True
4 changes: 2 additions & 2 deletions src/pymbe/interpretation/set_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ def create_set_with_new_instances(
new_list = []
m1_metatype = m1_type._metatype
m1_typename = m1_type.name
for m in range(0, quantities[index]):
for value_index in range(quantities[index]):
if m1_metatype in VALUE_HOLDER_TYPES:
new_list.append(
ValueHolder(
[],
m1_typename,
None,
m1_type,
m,
value_index,
)
)
else:
Expand Down
22 changes: 11 additions & 11 deletions src/pymbe/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ def __getitem__(self, key):
class Naming(Enum):
"""An enumeration for how to repr SysML elements"""

identifier = "IDENTIFIER"
long = "LONG"
qualified = "QUALIFIED"
short = "SHORT"
IDENTIFIER = "identifier"
LONG = "long"
QUALIFIED = "qualified"
SHORT = "short"

def get_name(self, element: "Element") -> str:
naming = self._value_ # pylint: disable=no-member
Expand All @@ -42,14 +42,14 @@ def get_name(self, element: "Element") -> str:
return f"<{element._metatype}({element.source} ←→ {element.target})>"

data = element._data
if naming == Naming.qualified:
if naming == Naming.QUALIFIED:
return f"""<{data["qualifiedName"]}>"""

if naming == Naming.identifier:
if naming == Naming.IDENTIFIER:
return f"""<{data["@id"]}>"""

name = data.get("name") or data["@id"]
if naming == Naming.short:
if naming == Naming.SHORT:
return f"<{name}>"
return f"""<{name} «{data["@type"]}»>"""

Expand All @@ -66,13 +66,13 @@ class Model: # pylint: disable=too-many-instance-attributes
all_relationships: Dict[str, "Element"] = field(default_factory=dict)
all_non_relationships: Dict[str, "Element"] = field(default_factory=dict)

ownedElement: ListOfNamedItems = field(default_factory=ListOfNamedItems)
ownedMetatype: Dict[str, List["Element"]] = field(default_factory=dict)
ownedRelationship: List["Element"] = field(default_factory=list)
ownedElement: ListOfNamedItems = field(default_factory=ListOfNamedItems) # pylint: disable=invalid-name
ownedMetatype: Dict[str, List["Element"]] = field(default_factory=dict) # pylint: disable=invalid-name
ownedRelationship: List["Element"] = field(default_factory=list) # pylint: disable=invalid-name

source: Any = None

_naming: Naming = Naming.long # The scheme to use for repr'ing the elements
_naming: Naming = Naming.LONG # The scheme to use for repr'ing the elements

def __post_init__(self):
self.elements = {
Expand Down
16 changes: 8 additions & 8 deletions src/pymbe/widget/diagram/part_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ class Config: # pylint: disable=too-few-public-methods
default_edge: Type[Relationship] = Field(default=DirectedAssociation)

symbols: SymbolSpec = SymbolSpec().add(
make_arrow_symbol(identifier="generalization", r=8, closed=True),
make_arrow_symbol(identifier="directed_association", r=8, closed=False),
make_containment_symbol(identifier="containment", r=8),
make_feature_typing_symbol(identifier="feature_typing", r=8),
make_redefinition_symbol(identifier="redefinition", r=8),
make_subsetting_symbol(identifier="subsetting", r=8),
make_rhombus_symbol(identifier="composition", r=8),
make_rhombus_symbol(identifier="aggregation", r=8),
make_arrow_symbol(identifier="generalization", size=8, closed=True),
make_arrow_symbol(identifier="directed_association", size=8, closed=False),
make_containment_symbol(identifier="containment", size=8),
make_feature_typing_symbol(identifier="feature_typing", size=8),
make_redefinition_symbol(identifier="redefinition", size=8),
make_subsetting_symbol(identifier="subsetting", size=8),
make_rhombus_symbol(identifier="composition", size=8),
make_rhombus_symbol(identifier="aggregation", size=8),
)

style: Dict[str, Dict] = {
Expand Down
64 changes: 32 additions & 32 deletions src/pymbe/widget/diagram/symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,167 +3,167 @@
from ipyelk.elements.symbol import EndpointSymbol


def make_arrow_symbol(identifier: str, r=6, closed=False) -> EndpointSymbol:
def make_arrow_symbol(identifier: str, size=6, closed=False) -> EndpointSymbol:
return EndpointSymbol(
element=Node(
children=[
Node(
properties=NodeProperties(
shape=Path.from_list(
[(r / 2, -r / 3), (0, 0), (r / 2, r / 3)],
[(size / 2, -size / 3), (0, 0), (size / 2, size / 3)],
closed=closed,
),
),
),
],
),
identifier=identifier,
path_offset=Point(x=(-r / 1.75) if closed else 0, y=0),
path_offset=Point(x=(-size / 1.75) if closed else 0, y=0),
symbol_offset=Point(x=-1, y=0),
)


def make_containment_symbol(identifier: str, r=6) -> EndpointSymbol:
def make_containment_symbol(identifier: str, size=6) -> EndpointSymbol:
return EndpointSymbol(
identifier=identifier,
element=Node(
children=[
Node(
properties=NodeProperties(
shape=Circle(
radius=r,
x=r,
radius=size,
x=size,
y=0,
)
)
),
Node(
properties=NodeProperties(
shape=Path.from_list([(0, 0), (2 * r, 0)]),
shape=Path.from_list([(0, 0), (2 * size, 0)]),
)
),
Node(
properties=NodeProperties(
shape=Path.from_list([(r, -r), (r, r)]),
shape=Path.from_list([(size, -size), (size, size)]),
)
),
]
),
symbol_offset=Point(x=-1, y=0),
path_offset=Point(x=-2 * r, y=0),
path_offset=Point(x=-2 * size, y=0),
)


def make_feature_typing_symbol(identifier: str, r=6) -> EndpointSymbol:
def make_feature_typing_symbol(identifier: str, size=6) -> EndpointSymbol:
return EndpointSymbol(
element=Node(
children=[
Node(
properties=NodeProperties(
shape=Circle(
radius=r / 20,
x=r * 4 / 5,
y=r / 4,
radius=size / 20,
x=size * 4 / 5,
y=size / 4,
),
),
),
Node(
properties=NodeProperties(
shape=Circle(
radius=r / 20,
x=r * 4 / 5,
y=-r / 4,
radius=size / 20,
x=size * 4 / 5,
y=-size / 4,
),
),
),
Node(
properties=NodeProperties(
shape=Path.from_list(
[(r / 2, -r / 3), (0, 0), (r / 2, r / 3)],
[(size / 2, -size / 3), (0, 0), (size / 2, size / 3)],
closed=True,
),
),
),
],
),
identifier=identifier,
path_offset=Point(x=-r / 1.75, y=0),
path_offset=Point(x=-size / 1.75, y=0),
symbol_offset=Point(x=-1, y=0),
)


def make_redefinition_symbol(identifier: str, r=6) -> EndpointSymbol:
def make_redefinition_symbol(identifier: str, size=6) -> EndpointSymbol:
return EndpointSymbol(
element=Node(
children=[
Node(
properties=NodeProperties(
shape=Path.from_list(
[(r * 4 / 5, -r / 3), (r * 4 / 5, r / 3)],
[(size * 4 / 5, -size / 3), (size * 4 / 5, size / 3)],
),
),
),
Node(
properties=NodeProperties(
shape=Path.from_list(
[(r / 2, -r / 3), (0, 0), (r / 2, r / 3)],
[(size / 2, -size / 3), (0, 0), (size / 2, size / 3)],
closed=True,
),
),
),
],
),
identifier=identifier,
path_offset=Point(x=-r / 1.75, y=0),
path_offset=Point(x=-size / 1.75, y=0),
symbol_offset=Point(x=-1, y=0),
)


def make_rhombus_symbol(identifier: str, r: float = 6) -> EndpointSymbol:
def make_rhombus_symbol(identifier: str, size: float = 6) -> EndpointSymbol:
return EndpointSymbol(
identifier=identifier,
element=Node(
properties=NodeProperties(
shape=Path.from_list(
[
(0, 0),
(r, r / 2),
(2 * r, 0),
(r, -r / 2),
(size, size / 2),
(2 * size, 0),
(size, -size / 2),
],
closed=True,
)
),
),
symbol_offset=Point(x=-1, y=0),
path_offset=Point(x=-2 * r, y=0),
path_offset=Point(x=-2 * size, y=0),
)


def make_subsetting_symbol(identifier: str, r=6) -> EndpointSymbol:
def make_subsetting_symbol(identifier: str, size=6) -> EndpointSymbol:
return EndpointSymbol(
element=Node(
children=[
Node(
properties=NodeProperties(
shape=Circle(
radius=r / 5,
x=r / 5,
radius=size / 5,
x=size / 5,
y=0,
),
),
),
Node(
properties=NodeProperties(
shape=Path.from_list(
[(r, -r / 2.5), (r / 2.5, 0), (r, r / 2.5)],
[(size, -size / 2.5), (size / 2.5, 0), (size, size / 2.5)],
closed=False,
),
),
),
],
),
identifier=identifier,
path_offset=Point(x=-r / 1.9, y=0),
path_offset=Point(x=-size / 1.9, y=0),
symbol_offset=Point(x=-1, y=0),
)

0 comments on commit 9047117

Please sign in to comment.