From 7f12e46f5a8935e6b6f862b2c2bdfe649c02cc42 Mon Sep 17 00:00:00 2001 From: vicky Date: Wed, 18 May 2022 21:30:56 +0200 Subject: [PATCH] added usage of split method --- src/bootstraparse/modules/export.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/bootstraparse/modules/export.py b/src/bootstraparse/modules/export.py index e5c5682..42d088c 100644 --- a/src/bootstraparse/modules/export.py +++ b/src/bootstraparse/modules/export.py @@ -1,7 +1,10 @@ # Module for final generation of the translated website +import rich + from bootstraparse.modules import config, pathresolver, error_mngr from collections import namedtuple +from bootstraparse.modules.syntax import split_optionals """ Named tuple containing all necessary information to select the appropriate @@ -22,15 +25,10 @@ def format_optionals(optionals): on one hand and var on the other hand. rtype: str """ - if optionals: - h, c = optionals.content.html_insert, optionals.content.class_insert # TODO : Simplify this - else: - return '' - if h != '': - h = h.content.html_insert - if c != '': - c = " ".join(c.content.class_insert) # TODO : Simplify this (sic.) - output = f'''{' '.join(h)}{' ' if h and c else ''}{f'class="{c}"' if c else ''}''' # The inconsistency is here with " and ' + split = split_optionals(optionals) + h = split.html_insert + c = split.class_insert + output = f'''{h}{' ' if h and c else ''}{f'class="{c}"' if c else ''}''' return output