extracting strip_html

This commit is contained in:
Vinicius Moreira
2019-09-04 11:59:26 -03:00
parent a812355efa
commit 5d1905a988
3 changed files with 4 additions and 11 deletions

View File

@@ -1,6 +1,5 @@
import glob import glob
import locale import locale
import re
from bauh_api.util import system from bauh_api.util import system
from bauh_api.util.resource import get_path from bauh_api.util.resource import get_path
@@ -8,8 +7,6 @@ from bauh_api.util.resource import get_path
from bauh import ROOT_DIR, __app_name__ from bauh import ROOT_DIR, __app_name__
from bauh.core import resource from bauh.core import resource
HTML_RE = re.compile(r'<[^>]+>')
def get_locale_keys(key: str = None, locale_dir: str = resource.get_path('locale')): def get_locale_keys(key: str = None, locale_dir: str = resource.get_path('locale')):
@@ -45,9 +42,5 @@ def get_locale_keys(key: str = None, locale_dir: str = resource.get_path('locale
return locale_obj return locale_obj
def strip_html(string: str):
return HTML_RE.sub('', string)
def notify_user(msg: str, icon_path: str = get_path('img/logo.svg', ROOT_DIR)): def notify_user(msg: str, icon_path: str = get_path('img/logo.svg', ROOT_DIR)):
system.notify_user(msg=msg, app_name=__app_name__, icon_path=icon_path) system.notify_user(msg=msg, app_name=__app_name__, icon_path=icon_path)

View File

@@ -9,9 +9,9 @@ from PyQt5.QtWidgets import QTableWidget, QTableView, QMenu, QAction, QTableWidg
QHeaderView, QLabel, QHBoxLayout, QPushButton, QToolBar QHeaderView, QLabel, QHBoxLayout, QPushButton, QToolBar
from bauh_api.abstract.cache import MemoryCache from bauh_api.abstract.cache import MemoryCache
from bauh_api.abstract.model import PackageStatus from bauh_api.abstract.model import PackageStatus
from bauh_api.util.html import strip_html
from bauh.core import resource from bauh.core import resource
from bauh.util import util
from bauh.view.qt import dialog from bauh.view.qt import dialog
from bauh.view.qt.view_model import PackageView, PackageViewStatus from bauh.view.qt.view_model import PackageView, PackageViewStatus
@@ -351,7 +351,7 @@ class AppsTable(QTableWidget):
desc = '...' desc = '...'
if desc and desc != '...': if desc and desc != '...':
desc = util.strip_html(desc[0:25]) + '...' desc = strip_html(desc[0:25]) + '...'
col.setText(desc) col.setText(desc)

View File

@@ -4,7 +4,7 @@ from PyQt5.QtWidgets import QDialog, QVBoxLayout, QGroupBox, \
QLineEdit, QLabel, QGridLayout, QPushButton, QPlainTextEdit, QToolBar QLineEdit, QLabel, QGridLayout, QPushButton, QPlainTextEdit, QToolBar
from bauh_api.abstract.cache import MemoryCache from bauh_api.abstract.cache import MemoryCache
from bauh.util import util from bauh_api.util.html import strip_html
IGNORED_ATTRS = {'name', '__app__'} IGNORED_ATTRS = {'name', '__app__'}
@@ -63,7 +63,7 @@ class InfoDialog(QDialog):
if len(val) > 80: if len(val) > 80:
full_val = val full_val = val
self.full_vals.append(full_val) self.full_vals.append(full_val)
val = util.strip_html(val) val = strip_html(val)
val = val[0:80] + '...' val = val[0:80] + '...'
text.setText(val) text.setText(val)