From afbfb63a000b6c1baf2445ac5d794d5b39024495 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Wed, 27 Mar 2019 10:44:30 -0400 Subject: [PATCH] Replace css-utils with css-parser The latter is a maintained fork that runs natively on python2/python3 (without using the fragile 2to3), fixes deprecations, and has a passing testsuite. --- README.md | 2 +- flatpak/org.gajim.Gajim.yaml | 10 ++++------ gajim/gtk/css_config.py | 14 +++++++------- mypy.ini | 4 ++-- setup.cfg | 5 ++--- win/_base.sh | 2 +- win/dev_env.sh | 2 +- 7 files changed, 18 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 7b8f7df2b..9d145d42c 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ ### Runtime Requirements - gir1.2-gtk-3.0 (>=3.22) - python3-nbxmpp (>=0.9.90.4) - python3-openssl (>=16.2) -- python3-cssutils (>=1.0.2) +- python3-css-parser - python3-keyring - python3-precis-i18n diff --git a/flatpak/org.gajim.Gajim.yaml b/flatpak/org.gajim.Gajim.yaml index 3f463c613..e8cbea9cc 100644 --- a/flatpak/org.gajim.Gajim.yaml +++ b/flatpak/org.gajim.Gajim.yaml @@ -147,16 +147,14 @@ modules: url: https://files.pythonhosted.org/packages/6e/b3/b4d443d2e30c00cdb73612426222172182e54359545cfb17774792619e49/keyring-19.0.2-py2.py3-none-any.whl sha256: afbfe7bc9bdba69d25c551b0c738adde533d87e0b51ad6bbe332cbea19ad8476 - - name: python3-cssutils + - name: python3-css-parser buildsystem: simple build-commands: - - pip3 install --prefix=/app cssutils-1.0.2-py3-none-any.whl - cleanup: - - /bin + - pip3 install --prefix=/app css-parser-1.0.4-py3-none-any.whl sources: - type: file - url: https://files.pythonhosted.org/packages/6b/15/a9fb9010f58d1c55dd0b7779db2334feb9a572d407024f39a60f44293861/cssutils-1.0.2-py3-none-any.whl - sha256: c74dbe19c92f5052774eadb15136263548dd013250f1ed1027988e7fef125c8d + url: https://files.pythonhosted.org/packages/py3/c/css_parser/css_parser-1.0.4-py3-none-any.whl + sha256: 49d6906416569e715b144df97ed81a94b6dc663fbcae6d1dbf4807e7fb8367ae - name: python3-precis_i18n buildsystem: simple diff --git a/gajim/gtk/css_config.py b/gajim/gtk/css_config.py index 7047a6b8c..64dbd6746 100644 --- a/gajim/gtk/css_config.py +++ b/gajim/gtk/css_config.py @@ -19,10 +19,10 @@ import math import logging -import cssutils from gi.repository import Gtk from gi.repository import Gdk from gi.repository import Pango +import css_parser from gajim.common import app from gajim.common import configpaths @@ -66,7 +66,7 @@ def __init__(self): css here.""" # Delete empty rules - cssutils.ser.prefs.keepEmptyRules = False + css_parser.ser.prefs.keepEmptyRules = False # Holds the currently selected theme in the Theme Editor self._pre_css = None @@ -202,16 +202,16 @@ def _load_selected(self, new_path=None): self._css_path = self._determine_theme_path() else: self._css_path = new_path - self._css = cssutils.parseFile(self._css_path) + self._css = css_parser.parseFile(self._css_path) def _load_default(self): self._default_css_path = self.get_theme_path('default', user=False) - self._default_css = cssutils.parseFile(self._default_css_path) + self._default_css = css_parser.parseFile(self._default_css_path) def _load_pre(self, theme): log.info('Preload theme %s', theme) self._pre_css_path = self.get_theme_path(theme) - self._pre_css = cssutils.parseFile(self._pre_css_path) + self._pre_css = css_parser.parseFile(self._pre_css_path) def _write(self, pre): path = self._css_path @@ -251,7 +251,7 @@ def set_value(self, selector, attr, value, pre=False): # The rule was not found, so we add it to this theme log.info('Set %s %s %s', selector, attr, value) - rule = cssutils.css.CSSStyleRule(selectorText=selector) + rule = css_parser.css.CSSStyleRule(selectorText=selector) rule.style[attr] = value css.add(rule) self._write(pre) @@ -282,7 +282,7 @@ def set_font(self, selector, description, pre=False): # The rule was not found, so we add it to this theme log.info('Set Font for: %s %s %s %s %s', selector, family, size, style, weight) - rule = cssutils.css.CSSStyleRule(selectorText=selector) + rule = css_parser.css.CSSStyleRule(selectorText=selector) rule.style['font-family'] = family rule.style['font-style'] = style rule.style['font-size'] = '%spt' % size diff --git a/mypy.ini b/mypy.ini index e9c1fb647..55fa3dde2 100644 --- a/mypy.ini +++ b/mypy.ini @@ -51,7 +51,7 @@ ignore_missing_imports = True [mypy-ossaudiodev.*] ignore_missing_imports = True -[mypy-cssutils.*] +[mypy-css_parser.*] ignore_missing_imports = True [mypy-distro.*] @@ -70,4 +70,4 @@ ignore_missing_imports = True ignore_missing_imports = True [mypy-cairo.*] -ignore_missing_imports = True \ No newline at end of file +ignore_missing_imports = True diff --git a/setup.cfg b/setup.cfg index 358dd6dc6..ad69f8ec7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [flake8] -ignore = +ignore = exclude = .git,__pycache__,.gitlab max-complexity = 15 builtins=_ @@ -20,7 +20,7 @@ python_requires = >=3.5 packages = find: test_suite = test install_requires = - cssutils>=1.0.2 + css-parser keyring nbxmpp>=0.9.92 precis-i18n>=1.0.0 @@ -45,4 +45,3 @@ gajim = exclude = gajim.dev test* - diff --git a/win/_base.sh b/win/_base.sh index c9730beab..3d4966272 100644 --- a/win/_base.sh +++ b/win/_base.sh @@ -105,7 +105,7 @@ keyring python-gnupg python-axolotl qrcode -cssutils +css_parser " build_pip install $(echo "$PIP_REQUIREMENTS" | tr ["\\n"] [" "]) diff --git a/win/dev_env.sh b/win/dev_env.sh index 6256c2706..973325a01 100644 --- a/win/dev_env.sh +++ b/win/dev_env.sh @@ -25,7 +25,7 @@ git+https://github.com/enthought/pywin32-ctypes.git python-axolotl python-gnupg keyring -cssutils +css_parser qrcode " pip3 install precis-i18n -- GitLab