Skip to content

Commit

Permalink
FIX: pylint linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ldevillez committed May 19, 2024
1 parent d56e983 commit c6d4d9b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
27 changes: 13 additions & 14 deletions svg2tikz/tikz_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ def get_shape_inside(self, node=None):
shape = inkex.properties.match_url_and_return_element(url, self.svg)
return shape

def style_to_tz(self, node=None):
def style_to_tz(self, node=None): # pylint: disable=too-many-branches
"""
Convert the style from the svg to the option to apply to tikz code
"""
Expand All @@ -815,14 +815,13 @@ def style_to_tz(self, node=None):
# No display of the node
# Special handling of switch as they are meta elements
if node.TAG == "switch":
pass
if style.get("display") == "none":
return ["none"]
else:
if style.get("display") == "none" or not node.is_visible:
if node.TAG == "g":
return ["none"]
return []

elif style.get("display") == "none" or not node.is_visible:
if node.TAG == "g":
return ["none"]
return []

options = []

Expand Down Expand Up @@ -864,13 +863,13 @@ def style_to_tz(self, node=None):
options.append(f"{tikzname}={data.get(value, '')}")
else:
options.append(data.get(value, ""))
elif valuetype == DIMENSION:
if value and value != data:
options.append(
f"{tikzname}="
f"{self.round_value(self.convert_unit(value))}"
f"{self.options.output_unit}"
)

elif valuetype == DIMENSION and value and value != data:
options.append(
f"{tikzname}="
f"{self.round_value(self.convert_unit(value))}"
f"{self.options.output_unit}"
)

# Arrow marker handling
options += self._handle_markers(style)
Expand Down
1 change: 1 addition & 0 deletions tests/test_complete_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from svg2tikz import convert_file


# pylint: disable=too-many-public-methods
def create_test_from_filename(filename, utest, filename_output=None, **kwargs):
"""
Function to test the complete conversion with svg2tikz.
Expand Down
2 changes: 2 additions & 0 deletions tests/test_geometrical_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
from svg2tikz.tikz_export import calc_arc


# pylint: disable=too-many-public-methods
class TestGeometricalFunctions(unittest.TestCase):
"""Test all functions related to geometry from tikz_export"""

# pylint: disable=too-many-statements
def test_calc_arc(self):
"""Test arc computing
Expand Down
7 changes: 6 additions & 1 deletion tests/test_tikz_path_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + "/../")

# pylint: disable=wrong-import-position
from inkex.transforms import Vector2d
from svg2tikz.tikz_export import TikZPathExporter
from tests.common import SVG_4_RECT, SVG_EMPTY, SVG_TEXT
from inkex.transforms import Vector2d


class TestTikZPathExporter(unittest.TestCase):
Expand Down Expand Up @@ -182,20 +182,23 @@ def test_handle_markers(self):
[[], ["->"], ["<-"], ["<->"]],
):
node = tzpe.svg.getElementById(id_node)
# pylint: disable=protected-access
out_markers = tzpe._handle_markers(node.specified_style())
self.assertEqual(expected_out, out_markers)

# Include options
tzpe.options.markings = "include"
for id_node in ["noA", "ar", "al", "arl", "a_r", "a_l", "a_rl", "ar_l"]:
node = tzpe.svg.getElementById(id_node)
# pylint: disable=protected-access
out_markers = tzpe._handle_markers(node.specified_style())
self.assertEqual(out_markers, [])

# Include options
tzpe.options.markings = "notAOption"
for id_node in ["noA", "ar", "al", "arl", "a_r", "a_l", "a_rl", "ar_l"]:
node = tzpe.svg.getElementById(id_node)
# pylint: disable=protected-access
out_markers = tzpe._handle_markers(node.specified_style())
self.assertEqual(out_markers, [])

Expand All @@ -205,6 +208,7 @@ def test_handle_shape(self):
tzpe.convert(StringIO(SVG_TEXT), no_output=True, returnstring=True)
text_node = tzpe.svg.getElementById("textNode")

# pylint: disable=protected-access
emtpy_str, empty_list = tzpe._handle_shape(text_node)
self.assertEqual(empty_list, [])
self.assertEqual(emtpy_str, "")
Expand All @@ -217,6 +221,7 @@ def test_handle_text(self):
)
text_node = tzpe.svg.getElementById("textNode")

# pylint: disable=protected-access
emtpy_str = tzpe._handle_text(text_node)
self.assertEqual(emtpy_str, "")

Expand Down
3 changes: 2 additions & 1 deletion tests/test_utility_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ def test_copy_to_clipboard(self):
self.assertTrue(copy_to_clipboard(b"Test text"))

def test_get_arg_parser(self):
"""Test getting the arg parser"""
arg_parser_doc = return_arg_parser_doc()
self.assertTrue(type(arg_parser_doc) == argparse.ArgumentParser)
self.assertTrue(isinstance(arg_parser_doc, argparse.ArgumentParser))

0 comments on commit c6d4d9b

Please sign in to comment.