Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
c08a2946
by Philipp Hörist at 2022-12-14T23:32:23+01:00
-
5651884d
by Philipp Hörist at 2022-12-14T23:36:31+01:00
14 changed files:
- gajim/common/helpers.py
- gajim/common/styling.py
- + gajim/common/util/__init__.py
- + gajim/common/util/classes.py
- gajim/common/text_helpers.py → gajim/common/util/text.py
- gajim/gtk/avatar.py
- gajim/gtk/chat_stack.py
- gajim/gtk/menus.py
- gajim/gtk/preview_audio.py
- gajim/gtk/vcard_grid.py
- gajim/plugins/pluginmanager.py
- pyproject.toml
- test/no_gui/test_styling.py
- test/no_gui/test_text_helpers.py → test/no_gui/test_text_util.py
Changes:
| ... | ... | @@ -823,17 +823,6 @@ def copy(self) -> AdditionalDataDict: |
| 823 | 823 | return copy.deepcopy(self)
|
| 824 | 824 | |
| 825 | 825 | |
| 826 | -class Singleton(type):
|
|
| 827 | - |
|
| 828 | - _instances: dict[Any, Any] = {}
|
|
| 829 | - |
|
| 830 | - def __call__(cls, *args: Any, **kwargs: Any):
|
|
| 831 | - if cls not in cls._instances:
|
|
| 832 | - cls._instances[cls] = super().__call__(
|
|
| 833 | - *args, **kwargs)
|
|
| 834 | - return cls._instances[cls]
|
|
| 835 | - |
|
| 836 | - |
|
| 837 | 826 | def delay_execution(milliseconds):
|
| 838 | 827 | # Delay the first call for `milliseconds`
|
| 839 | 828 | # ignore all other calls while the delay is active
|
| ... | ... | @@ -30,7 +30,7 @@ |
| 30 | 30 | from gajim.common.const import URIType
|
| 31 | 31 | from gajim.common.helpers import parse_uri as analyze_uri
|
| 32 | 32 | from gajim.common.helpers import validate_jid
|
| 33 | -from gajim.common.text_helpers import escape_iri_query
|
|
| 33 | +from gajim.common.util.text import escape_iri_query
|
|
| 34 | 34 | |
| 35 | 35 | PRE = '`'
|
| 36 | 36 | STRONG = '*'
|
| 1 | +# This file is part of Gajim.
|
|
| 2 | +#
|
|
| 3 | +# Gajim is free software; you can redistribute it and/or modify
|
|
| 4 | +# it under the terms of the GNU General Public License as published
|
|
| 5 | +# by the Free Software Foundation; version 3 only.
|
|
| 6 | +#
|
|
| 7 | +# Gajim is distributed in the hope that it will be useful,
|
|
| 8 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 9 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 10 | +# GNU General Public License for more details.
|
|
| 11 | +#
|
|
| 12 | +# You should have received a copy of the GNU General Public License
|
|
| 13 | +# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
| 14 | + |
|
| 15 | + |
|
| 16 | +from __future__ import annotations
|
|
| 17 | + |
|
| 18 | +from typing import Any
|
|
| 19 | + |
|
| 20 | + |
|
| 21 | +class Singleton(type):
|
|
| 22 | + |
|
| 23 | + _instances: dict[Any, Any] = {}
|
|
| 24 | + |
|
| 25 | + def __call__(cls, *args: Any, **kwargs: Any):
|
|
| 26 | + if cls not in cls._instances:
|
|
| 27 | + cls._instances[cls] = super().__call__(
|
|
| 28 | + *args, **kwargs)
|
|
| 29 | + return cls._instances[cls] |
| ... | ... | @@ -34,10 +34,10 @@ |
| 34 | 34 | from gajim.common import types
|
| 35 | 35 | from gajim.common import app
|
| 36 | 36 | from gajim.common import configpaths
|
| 37 | -from gajim.common.helpers import Singleton
|
|
| 38 | 37 | from gajim.common.helpers import get_groupchat_name
|
| 39 | 38 | from gajim.common.const import AvatarSize
|
| 40 | 39 | from gajim.common.const import StyleAttr
|
| 40 | +from gajim.common.util.classes import Singleton
|
|
| 41 | 41 | |
| 42 | 42 | from .const import DEFAULT_WORKSPACE_COLOR
|
| 43 | 43 | from .util import get_contact_color
|
| ... | ... | @@ -44,7 +44,7 @@ |
| 44 | 44 | from gajim.common.preview_helpers import split_geo_uri
|
| 45 | 45 | from gajim.common.preview_helpers import format_geo_coords
|
| 46 | 46 | from gajim.common.structs import OutgoingMessage
|
| 47 | -from gajim.common.text_helpers import remove_invalid_xml_chars
|
|
| 47 | +from gajim.common.util.text import remove_invalid_xml_chars
|
|
| 48 | 48 | from gajim.common.types import ChatContactT
|
| 49 | 49 | |
| 50 | 50 | from .chat_banner import ChatBanner
|
| ... | ... | @@ -45,7 +45,7 @@ |
| 45 | 45 | from gajim.common.const import XmppUriQuery
|
| 46 | 46 | from gajim.common.preview import Preview
|
| 47 | 47 | from gajim.common.structs import URI
|
| 48 | -from gajim.common.text_helpers import escape_iri_path_segment
|
|
| 48 | +from gajim.common.util.text import escape_iri_path_segment
|
|
| 49 | 49 | from gajim.common.modules.contacts import GroupchatContact
|
| 50 | 50 | from gajim.common.modules.contacts import can_add_to_roster
|
| 51 | 51 |
| ... | ... | @@ -30,7 +30,7 @@ |
| 30 | 30 | |
| 31 | 31 | from gajim.common import app
|
| 32 | 32 | from gajim.common.i18n import _
|
| 33 | -from gajim.common.text_helpers import format_duration
|
|
| 33 | +from gajim.common.util.text import format_duration
|
|
| 34 | 34 | from gajim.common.preview import AudioSampleT
|
| 35 | 35 | |
| 36 | 36 | from .builder import get_builder
|
| ... | ... | @@ -30,7 +30,7 @@ |
| 30 | 30 | from gajim.common.helpers import open_uri
|
| 31 | 31 | from gajim.common.helpers import parse_uri
|
| 32 | 32 | from gajim.common.structs import URI
|
| 33 | -from gajim.common.text_helpers import escape_iri_path_segment
|
|
| 33 | +from gajim.common.util.text import escape_iri_path_segment
|
|
| 34 | 34 | from gajim.gui.util import gtk_month
|
| 35 | 35 | from gajim.gui.util import python_month
|
| 36 | 36 |
| ... | ... | @@ -42,7 +42,7 @@ |
| 42 | 42 | from gajim.common.events import PluginRemoved
|
| 43 | 43 | from gajim.common.i18n import _
|
| 44 | 44 | from gajim.common.exceptions import PluginsystemError
|
| 45 | -from gajim.common.helpers import Singleton
|
|
| 45 | +from gajim.common.util.classes import Singleton
|
|
| 46 | 46 | from gajim.plugins.plugins_i18n import _ as p_
|
| 47 | 47 | |
| 48 | 48 | from gajim.plugins.helpers import GajimPluginActivateException
|
| ... | ... | @@ -57,7 +57,7 @@ include = [ |
| 57 | 57 | "gajim/common/storage/*",
|
| 58 | 58 | "gajim/common/styling.py",
|
| 59 | 59 | "gajim/common/task_manager.py",
|
| 60 | - "gajim/common/text_helpers.py",
|
|
| 60 | + "gajim/common/util/*",
|
|
| 61 | 61 | "gajim/gajim.py",
|
| 62 | 62 | "gajim/gajim_remote.py",
|
| 63 | 63 | "gajim/gtk/about.py",
|
| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | from gajim.common.styling import StrikeSpan
|
| 16 | 16 | from gajim.common.styling import Hyperlink
|
| 17 | 17 | from gajim.common.styling import process_uris
|
| 18 | -from gajim.common.text_helpers import escape_iri_query
|
|
| 18 | +from gajim.common.util.text import escape_iri_query
|
|
| 19 | 19 | |
| 20 | 20 | |
| 21 | 21 | app.settings = MagicMock()
|
| 1 | 1 | import unittest
|
| 2 | 2 | |
| 3 | -from gajim.common.text_helpers import escape_iri_path_segment
|
|
| 4 | -from gajim.common.text_helpers import jid_to_iri
|
|
| 5 | -from gajim.common.text_helpers import format_duration
|
|
| 6 | -from gajim.common.text_helpers import remove_invalid_xml_chars
|
|
| 3 | +from gajim.common.util.text import escape_iri_path_segment
|
|
| 4 | +from gajim.common.util.text import jid_to_iri
|
|
| 5 | +from gajim.common.util.text import format_duration
|
|
| 6 | +from gajim.common.util.text import remove_invalid_xml_chars
|
|
| 7 | 7 | |
| 8 | 8 | |
| 9 | 9 | class Test(unittest.TestCase):
|