--- a/ProjectDjangoTagsMenu/DjangoTagsMenuHandler.py Sat Dec 23 15:48:51 2023 +0100 +++ b/ProjectDjangoTagsMenu/DjangoTagsMenuHandler.py Sat Dec 23 16:54:25 2023 +0100 @@ -166,7 +166,7 @@ ) menu.addSeparator() menu.addAction( - self.tr("regroup - Regroup list of alike objects by a common" " attribute"), + self.tr("regroup - Regroup list of alike objects by a common attribute"), lambda: self.__applyTemplate("regroup"), ) menu.addSeparator() @@ -187,7 +187,7 @@ ) menu.addSeparator() menu.addAction( - self.tr("templatetag - Output syntax characters used for" " template"), + self.tr("templatetag - Output syntax characters used for template"), lambda: self.__applyTemplate("templatetag"), ) menu.addSeparator() @@ -428,7 +428,7 @@ ) menu.addAction( self.tr( - "truncatewords_html - Truncate after a number of words" " (HTML aware)" + "truncatewords_html - Truncate after a number of words (HTML aware)" ), lambda: self.__applyTemplate("truncatewords_html"), ) @@ -450,7 +450,7 @@ lambda: self.__applyTemplate("urlize"), ) menu.addAction( - self.tr("urlizetrunc - Convert URLs as clickable links and" " truncate"), + self.tr("urlizetrunc - Convert URLs as clickable links and truncate"), lambda: self.__applyTemplate("urlizetrunc"), ) menu.addSeparator() @@ -669,7 +669,7 @@ lambda: self.__applyTemplate("get_available_languages"), ) menu.addAction( - self.tr("get_current_language_bidi - Current language's" " direction"), + self.tr("get_current_language_bidi - Current language's direction"), lambda: self.__applyTemplate("get_current_language_bidi"), ) menu.addAction( @@ -767,7 +767,7 @@ lambda: self.__applyTemplate("timezone_set"), ) menu.addAction( - self.tr("timezone None - Unset timezone for date and time" " conversion"), + self.tr("timezone None - Unset timezone for date and time conversion"), lambda: self.__applyTemplate("timezone_unset"), ) menu.addAction( @@ -797,9 +797,9 @@ """ Private slot to find a template tag and insert its text. """ + from .FindTemplateTagDialog import FindTemplateTagDialog + if self.__findDialog is None: - from .FindTemplateTagDialog import FindTemplateTagDialog - self.__findDialog = FindTemplateTagDialog() self.__findDialog.tag.connect(self.__applyTemplate) self.__findDialog.show() @@ -839,6 +839,12 @@ a replace operation @rtype tuple of (str, bool) """ + from .IeCommentDialog import IeCommentDialog + from .IfTagInputDialog import IfTagInputDialog + from .LoremTagInputDialog import LoremTagInputDialog + from .MultiLineInputDialog import MultiLineInputDialog + from .TimezoneSelectionDialog import TimezoneSelectionDialog + replace = False # safe value ok = True templateText = "" @@ -956,8 +962,6 @@ ) replace = True elif tag == "if": - from .IfTagInputDialog import IfTagInputDialog - dlg = IfTagInputDialog() if dlg.exec() == QDialog.DialogCode.Accepted: templateText = dlg.getTag() @@ -1559,8 +1563,6 @@ elif tag == "loadweb": templateText = "{% load webdesign %}" elif tag == "lorem": - from .LoremTagInputDialog import LoremTagInputDialog - dlg = LoremTagInputDialog() if dlg.exec() == QDialog.DialogCode.Accepted: templateText = "{{% {0} %}}".format(dlg.getTag()) @@ -1584,7 +1586,7 @@ data, ok = DjangoTagInputDialog.getText( None, self.tr("Link to static file"), - [self.tr("Enter variable containing relative path of" " static file:")], + [self.tr("Enter variable containing relative path of static file:")], ["user_stylesheet"], ) if ok: @@ -1611,8 +1613,6 @@ if ok: templateText = "{{# {0} #}}".format(data[0]) elif tag == "multilinecommentdialog": - from .MultiLineInputDialog import MultiLineInputDialog - comment, ok = MultiLineInputDialog.getText( None, self.tr("Multi Line Comment"), self.tr("Enter comment:"), "" ) @@ -1655,8 +1655,6 @@ templateText = "<!-- {0} -->".format(selectedText) replace = True elif tag == "iecomment": - from .IeCommentDialog import IeCommentDialog - tag, ok = IeCommentDialog.getTag(selectedText) if ok: templateText = "<!--{0}-->".format(tag) @@ -1695,7 +1693,7 @@ data, ok = DjangoTagInputDialog.getText( None, self.tr("Translate Block with Attributes"), - [self.tr("Enter attribute binding expressions" " (space separated):")], + [self.tr("Enter attribute binding expressions (space separated):")], ["myvar1=value1 myvar2=value2"], ) if ok: @@ -1741,14 +1739,12 @@ data[0] ) else: - templateText = ( - "{% get_language_info for LANGUAGE_CODE" " as lang %}" - ) + templateText = "{% get_language_info for LANGUAGE_CODE as lang %}" elif tag == "get_language_info_list": data, ok = DjangoTagInputDialog.getText( None, self.tr("Language Information for a list of languages"), - [self.tr("Enter language list variable (empty for" " LANGUAGES):")], + [self.tr("Enter language list variable (empty for LANGUAGES):")], ["available_languages"], ) if ok: @@ -1759,9 +1755,7 @@ ) ) else: - templateText = ( - "{% get_language_info_list for LANGUAGES" " as langs %}" - ) + templateText = "{% get_language_info_list for LANGUAGES as langs %}" ## Filters ## elif tag == "language_name": templateText = "|language_name" @@ -1811,8 +1805,6 @@ ) replace = True elif tag == "timezone_set": - from .TimezoneSelectionDialog import TimezoneSelectionDialog - timezone, ok = TimezoneSelectionDialog.getTimezone() if ok: templateText = '{{% timezone "{0}" %}}{1}{{% endtimezone %}}'.format( @@ -1832,8 +1824,6 @@ elif tag == "utc": templateText = "|utc" elif tag == "timezone": - from .TimezoneSelectionDialog import TimezoneSelectionDialog - timezone, ok = TimezoneSelectionDialog.getTimezone() if ok: templateText = '|timezone:"{0}"'.format(timezone)