diff --git a/svg2tikz/tikz_export.py b/svg2tikz/tikz_export.py index 7352c96..fe7b248 100644 --- a/svg2tikz/tikz_export.py +++ b/svg2tikz/tikz_export.py @@ -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 """ @@ -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 = [] @@ -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) diff --git a/tests/test_complete_files.py b/tests/test_complete_files.py index c186ece..d216c99 100644 --- a/tests/test_complete_files.py +++ b/tests/test_complete_files.py @@ -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. diff --git a/tests/test_geometrical_functions.py b/tests/test_geometrical_functions.py index f4ed6b8..14ec953 100644 --- a/tests/test_geometrical_functions.py +++ b/tests/test_geometrical_functions.py @@ -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 diff --git a/tests/test_tikz_path_exporter.py b/tests/test_tikz_path_exporter.py index 429dfa6..68f3204 100644 --- a/tests/test_tikz_path_exporter.py +++ b/tests/test_tikz_path_exporter.py @@ -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): @@ -182,6 +182,7 @@ 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) @@ -189,6 +190,7 @@ def test_handle_markers(self): 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, []) @@ -196,6 +198,7 @@ def test_handle_markers(self): 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, []) @@ -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, "") @@ -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, "") diff --git a/tests/test_utility_functions.py b/tests/test_utility_functions.py index b9b1c33..af52d74 100644 --- a/tests/test_utility_functions.py +++ b/tests/test_utility_functions.py @@ -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))