diff --git a/graphviz2drawio/models/Rect.py b/graphviz2drawio/models/Rect.py index f4e39f5..e8d21d0 100644 --- a/graphviz2drawio/models/Rect.py +++ b/graphviz2drawio/models/Rect.py @@ -10,20 +10,18 @@ def __init__(self, x, y, width, height) -> None: def x_ratio(self, search): if search < self.x: return 0 - elif search > self.x + self.width: + if search > self.x + self.width: return 1 - else: - ratio = (search - self.x) / self.width - return self._approx(ratio, 0.5, 0.1) + ratio = (search - self.x) / self.width + return self._approx(ratio, 0.5, 0.1) def y_ratio(self, search): if search < self.y: return 0 - elif search > self.y + self.height: + if search > self.y + self.height: return 1 - else: - ratio = (search - self.y) / self.height - return self._approx(ratio, 0.5, 0.1) + ratio = (search - self.y) / self.height + return self._approx(ratio, 0.5, 0.1) @staticmethod def _approx(value, center, delta): diff --git a/graphviz2drawio/mx/Edge.py b/graphviz2drawio/mx/Edge.py index e316803..e0c1f7e 100644 --- a/graphviz2drawio/mx/Edge.py +++ b/graphviz2drawio/mx/Edge.py @@ -26,8 +26,7 @@ def __init__( def curve_start_end(self): if self.dir == DotAttr.BACK: return self.curve.end, self.curve.start - else: - return self.curve.start, self.curve.end + return self.curve.start, self.curve.end @property def key_for_label(self) -> str: diff --git a/graphviz2drawio/mx/LinearRegression.py b/graphviz2drawio/mx/LinearRegression.py index 732cd14..dd6be4e 100644 --- a/graphviz2drawio/mx/LinearRegression.py +++ b/graphviz2drawio/mx/LinearRegression.py @@ -28,8 +28,7 @@ def determination(points, y_mean, b0, b1) -> float: sst.append(diff**2) if sum(sst) == 0: return 1 # Horizontal line - else: - return 1 - (sum(sse) / sum(sst)) + return 1 - (sum(sse) / sum(sst)) def coefficients(points: list) -> list[float]: @@ -44,5 +43,4 @@ def coefficients(points: list) -> list[float]: b0 = m.imag - b1 * m.real r2 = determination(points, m.imag, b0, b1) return [b0, b1, r2] - else: - return [0, 0, 1] # Vertical line + return [0, 0, 1] # Vertical line diff --git a/graphviz2drawio/mx/MxGraph.py b/graphviz2drawio/mx/MxGraph.py index 7553226..9745197 100644 --- a/graphviz2drawio/mx/MxGraph.py +++ b/graphviz2drawio/mx/MxGraph.py @@ -60,8 +60,7 @@ def add_edge(self, edge) -> None: def get_edge_source_target(self, edge): if edge.dir == DotAttr.BACK: return self.nodes[edge.to], self.nodes[edge.fr] - else: - return self.nodes[edge.fr], self.nodes[edge.to] + return self.nodes[edge.fr], self.nodes[edge.to] @staticmethod def get_edge_style(edge, source_node, target_node): diff --git a/graphviz2drawio/mx/Styles.py b/graphviz2drawio/mx/Styles.py index 0a2887f..ddc4c70 100644 --- a/graphviz2drawio/mx/Styles.py +++ b/graphviz2drawio/mx/Styles.py @@ -72,70 +72,69 @@ class Styles(Enum): def get_for_shape(dot_shape): if dot_shape in (None, Shape.ELLIPSE, Shape.OVAL): return Styles.ELLIPSE - elif dot_shape in (Shape.BOX, Shape.RECT, Shape.RECTANGLE): + if dot_shape in (Shape.BOX, Shape.RECT, Shape.RECTANGLE): return Styles.NODE - elif dot_shape in (Shape.HEXAGON, Shape.POLYGON): + if dot_shape in (Shape.HEXAGON, Shape.POLYGON): return Styles.HEXAGON - elif dot_shape == Shape.CIRCLE: + if dot_shape == Shape.CIRCLE: return Styles.CIRCLE - elif dot_shape == Shape.EGG: + if dot_shape == Shape.EGG: return Styles.EGG - elif dot_shape == Shape.TRIANGLE: + if dot_shape == Shape.TRIANGLE: return Styles.TRIANGLE - elif dot_shape == Shape.PLAIN: + if dot_shape == Shape.PLAIN: return Styles.LINE - elif dot_shape == Shape.DIAMOND: + if dot_shape == Shape.DIAMOND: return Styles.DIAMOND - elif dot_shape == Shape.TRAPEZIUM: + if dot_shape == Shape.TRAPEZIUM: return Styles.TRAPEZOID - elif dot_shape == Shape.PARALLELOGRAM: + if dot_shape == Shape.PARALLELOGRAM: return Styles.PARALLELOGRAM - elif dot_shape == Shape.HOUSE: + if dot_shape == Shape.HOUSE: return Styles.HOUSE - elif dot_shape == Shape.PENTAGON: + if dot_shape == Shape.PENTAGON: return Styles.PENTAGON - elif dot_shape == Shape.OCTAGON: + if dot_shape == Shape.OCTAGON: return Styles.OCTAGON - elif dot_shape == Shape.DOUBLE_CIRCLE: + if dot_shape == Shape.DOUBLE_CIRCLE: return Styles.DOUBLE_CIRCLE - elif dot_shape == Shape.DOUBLE_OCTAGON: + if dot_shape == Shape.DOUBLE_OCTAGON: return Styles.DOUBLE_OCTAGON - elif dot_shape == Shape.INV_TRIANGLE: + if dot_shape == Shape.INV_TRIANGLE: return Styles.INV_TRIANGLE - elif dot_shape == Shape.INV_TRAPEZIUM: + if dot_shape == Shape.INV_TRAPEZIUM: return Styles.INV_TRAPEZOID - elif dot_shape == Shape.INV_HOUSE: + if dot_shape == Shape.INV_HOUSE: return Styles.INV_HOUSE - elif dot_shape == Shape.SQUARE: + if dot_shape == Shape.SQUARE: return Styles.SQUARE - elif dot_shape == Shape.STAR: + if dot_shape == Shape.STAR: return Styles.STAR - elif dot_shape == Shape.UNDERLINE: + if dot_shape == Shape.UNDERLINE: return Styles.UNDERLINE - elif dot_shape == Shape.CYLINDER: + if dot_shape == Shape.CYLINDER: return Styles.CYLINDER - elif dot_shape == Shape.NOTE: + if dot_shape == Shape.NOTE: return Styles.NODE - elif dot_shape == Shape.TAB: + if dot_shape == Shape.TAB: return Styles.TAB - elif dot_shape == Shape.FOLDER: + if dot_shape == Shape.FOLDER: return Styles.FOLDER - elif dot_shape == Shape.BOX_3D: + if dot_shape == Shape.BOX_3D: return Styles.CUBE - elif dot_shape == Shape.COMPONENT: + if dot_shape == Shape.COMPONENT: return Styles.COMPONENT - elif dot_shape in (Shape.PROMOTER, Shape.RPROMOTER): + if dot_shape in (Shape.PROMOTER, Shape.RPROMOTER): return Styles.RPROMOTER - elif dot_shape == Shape.LPROMOTER: + if dot_shape == Shape.LPROMOTER: return Styles.LPROMOTER - elif dot_shape == Shape.CDS: + if dot_shape == Shape.CDS: return Styles.CDS - elif dot_shape == Shape.RARROW: + if dot_shape == Shape.RARROW: return Styles.RARROW - elif dot_shape == Shape.LARROW: + if dot_shape == Shape.LARROW: return Styles.LARROW - else: - return Styles.NODE + return Styles.NODE def format(self, **values): return self.value.format(**values)