Skip to content

Commit

Permalink
Fix lint + Improve coherence
Browse files Browse the repository at this point in the history
  • Loading branch information
FabienRoger committed Dec 9, 2021
1 parent 5af131e commit 9aef64a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
6 changes: 4 additions & 2 deletions opencodeblocks/graphics/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,10 @@ def oneFileSaveAsJupyter(self) -> bool:
"""
current_window = self.activeMdiChild()
if current_window is not None:
filename, _ = QFileDialog.getSaveFileName(
self, "Save ipygraph to ipynb file"
dialog = QFileDialog()
dialog.setDefaultSuffix(".ipynb")
filename, _ = dialog.getSaveFileName(
self, "Save ipygraph to file", filter="IPython Graph (*.ipynb)"
)
if filename == "":
return False
Expand Down
13 changes: 7 additions & 6 deletions opencodeblocks/scene/from_ipynb_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

from typing import OrderedDict, List

from opencodeblocks.scene.ipynb_conversion_constants import *
from PyQt5.QtGui import QFontMetrics, QFont

from opencodeblocks.scene.ipynb_conversion_constants import *
from opencodeblocks.graphics.theme_manager import theme_manager
from opencodeblocks.graphics.pyeditor import POINT_SIZE
from PyQt5.QtGui import QFontMetrics, QFont


def ipynb_to_ipyg(data: OrderedDict) -> OrderedDict:
Expand Down Expand Up @@ -50,8 +50,6 @@ def get_blocks_data(data: OrderedDict) -> List[OrderedDict]:

text: str = cell["source"]

text_bouding_box = fontmetrics.boundingRect("".join(text))

text_width: float = (
max(fontmetrics.boundingRect(line).width() for line in text)
if len(text) > 0
Expand Down Expand Up @@ -103,7 +101,6 @@ def get_blocks_data(data: OrderedDict) -> List[OrderedDict]:

def is_title(block_data: OrderedDict) -> bool:
"""Checks if the block is a one-line markdown block which could correspond to a title"""

if block_data["block_type"] != BLOCK_TYPE_TO_NAME["markdown"]:
return False
if "\n" in block_data["text"]:
Expand All @@ -117,7 +114,10 @@ def is_title(block_data: OrderedDict) -> bool:


def adujst_markdown_blocks_width(blocks_data: OrderedDict) -> None:
"""Modify the markdown blocks width (in place) for them to match the width of block of code below"""
"""
Modify the markdown blocks width (in place)
For them to match the width of block of code below
"""
i: int = len(blocks_data) - 1

while i >= 0:
Expand Down Expand Up @@ -191,6 +191,7 @@ def get_edge_data(
edge_end_block_id: int,
edge_end_socket_id: int,
) -> OrderedDict:
"""Return the ordered dict corresponding to the given parameters"""
return {
"id": edge_id,
"source": {"block": edge_start_block_id, "socket": edge_start_socket_id},
Expand Down
2 changes: 2 additions & 0 deletions opencodeblocks/scene/ipynb_conversion_constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
""" Module with the constants used to converter to ipynb and from ipynb """

from typing import Dict

MARGIN_X: float = 75
Expand Down

0 comments on commit 9aef64a

Please sign in to comment.