From db30ad85c6298d2cafafd18e6035f425ece06f6c Mon Sep 17 00:00:00 2001 From: qutebrowser bot Date: Mon, 9 Nov 2020 04:34:33 +0000 Subject: Update dependencies --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'requirements.txt') diff --git a/requirements.txt b/requirements.txt index 7537cb3bf..ce4d80400 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ # This file is automatically generated by scripts/dev/recompile_requirements.py -attrs==20.2.0 +attrs==20.3.0 colorama==0.4.4 cssutils==1.0.2 Jinja2==2.11.2 -- cgit v1.2.3-54-g00ecf From 6acd40a38379fc9c2d6b80b19d75c94e6094452d Mon Sep 17 00:00:00 2001 From: duthades Date: Wed, 11 Nov 2020 10:12:21 +0530 Subject: Remove cssutils dependency - Remove everything related to cssutils --- .mypy.ini | 4 -- README.asciidoc | 2 - misc/requirements/requirements-dev.txt | 1 - misc/requirements/requirements-dev.txt-raw | 1 - misc/requirements/requirements-qutebrowser.txt-raw | 1 - misc/requirements/requirements-tests-git.txt | 1 - qutebrowser/browser/webkit/mhtml.py | 53 +--------------------- qutebrowser/utils/version.py | 1 - requirements.txt | 1 - scripts/dev/recompile_requirements.py | 1 - tests/unit/browser/webkit/test_mhtml.py | 35 ++++---------- tests/unit/utils/test_version.py | 5 -- 12 files changed, 12 insertions(+), 94 deletions(-) (limited to 'requirements.txt') diff --git a/.mypy.ini b/.mypy.ini index dfef7d3e5..d629f012c 100644 --- a/.mypy.ini +++ b/.mypy.ini @@ -36,10 +36,6 @@ ignore_missing_imports = True # https://bitbucket.org/birkenfeld/pygments-main/issues/1485/type-hints ignore_missing_imports = True -[mypy-cssutils] -# Pretty much inactive currently -ignore_missing_imports = True - [mypy-pypeg2] # Pretty much inactive currently ignore_missing_imports = True diff --git a/README.asciidoc b/README.asciidoc index a3cf8b270..5437036be 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -134,8 +134,6 @@ The following software and libraries are required to run qutebrowser: The following libraries are optional: -* http://cthedot.de/cssutils/[cssutils] (for an improved `:download --mhtml` - with QtWebKit). * On Windows, https://pypi.python.org/pypi/colorama/[colorama] for colored log output. * http://asciidoc.org/[asciidoc] to generate the documentation for the `:help` diff --git a/misc/requirements/requirements-dev.txt b/misc/requirements/requirements-dev.txt index ed83ef302..13956d51f 100644 --- a/misc/requirements/requirements-dev.txt +++ b/misc/requirements/requirements-dev.txt @@ -6,7 +6,6 @@ cffi==1.14.3 chardet==3.0.4 colorama==0.4.4 cryptography==3.2.1 -cssutils==1.0.2 github3.py==1.3.0 hunter==3.3.1 idna==2.10 diff --git a/misc/requirements/requirements-dev.txt-raw b/misc/requirements/requirements-dev.txt-raw index e7758f167..fd840bab1 100644 --- a/misc/requirements/requirements-dev.txt-raw +++ b/misc/requirements/requirements-dev.txt-raw @@ -1,5 +1,4 @@ hunter -cssutils pympler github3.py bump2version diff --git a/misc/requirements/requirements-qutebrowser.txt-raw b/misc/requirements/requirements-qutebrowser.txt-raw index c66c65beb..4678b9ce5 100644 --- a/misc/requirements/requirements-qutebrowser.txt-raw +++ b/misc/requirements/requirements-qutebrowser.txt-raw @@ -3,5 +3,4 @@ Pygments pyPEG2 PyYAML colorama -cssutils attrs diff --git a/misc/requirements/requirements-tests-git.txt b/misc/requirements/requirements-tests-git.txt index 14b6eec04..9efbeca40 100644 --- a/misc/requirements/requirements-tests-git.txt +++ b/misc/requirements/requirements-tests-git.txt @@ -27,7 +27,6 @@ git+https://github.com/pallets/werkzeug.git ## qutebrowser dependencies git+https://github.com/tartley/colorama.git -hg+https://bitbucket.org/cthedot/cssutils git+https://github.com/pallets/jinja.git git+https://github.com/pallets/markupsafe.git hg+http://bitbucket.org/birkenfeld/pygments-main diff --git a/qutebrowser/browser/webkit/mhtml.py b/qutebrowser/browser/webkit/mhtml.py index 6e2442575..794e1b73b 100644 --- a/qutebrowser/browser/webkit/mhtml.py +++ b/qutebrowser/browser/webkit/mhtml.py @@ -62,7 +62,7 @@ _CSS_URL_PATTERNS = [re.compile(x) for x in [ ]] -def _get_css_imports_regex(data): +def _get_css_imports(data): """Return all assets that are referenced in the given CSS document. The returned URLs are relative to the stylesheet's URL. @@ -79,55 +79,6 @@ def _get_css_imports_regex(data): return urls -def _get_css_imports_cssutils(data, inline=False): - """Return all assets that are referenced in the given CSS document. - - The returned URLs are relative to the stylesheet's URL. - - Args: - data: The content of the stylesheet to scan as string. - inline: True if the argument is an inline HTML style attribute. - """ - try: - import cssutils - except ImportError: - return None - - # We don't care about invalid CSS data, this will only litter the log - # output with CSS errors - parser = cssutils.CSSParser(loglevel=100, - fetcher=lambda url: (None, ""), validate=False) - if not inline: - sheet = parser.parseString(data) - return list(cssutils.getUrls(sheet)) - else: - urls = [] - declaration = parser.parseStyle(data) - # prop = background, color, margin, ... - for prop in declaration: - # value = red, 10px, url(foobar), ... - for value in prop.propertyValue: - if isinstance(value, cssutils.css.URIValue): - if value.uri: - urls.append(value.uri) - return urls - - -def _get_css_imports(data, inline=False): - """Return all assets that are referenced in the given CSS document. - - The returned URLs are relative to the stylesheet's URL. - - Args: - data: The content of the stylesheet to scan as string. - inline: True if the argument is an inline HTML style attribute. - """ - imports = _get_css_imports_cssutils(data, inline) - if imports is None: - imports = _get_css_imports_regex(data) - return imports - - def _check_rel(element): """Return true if the element's rel attribute fits our criteria. @@ -328,7 +279,7 @@ class _Downloader: for element in web_frame.findAllElements('[style]'): element = webkitelem.WebKitElement(element, tab=self.tab) style = element['style'] - for element_url in _get_css_imports(style, inline=True): + for element_url in _get_css_imports(style): self._fetch_url(web_url.resolved(QUrl(element_url))) # Shortcut if no assets need to be downloaded, otherwise the file would diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py index fa855d771..032563478 100644 --- a/qutebrowser/utils/version.py +++ b/qutebrowser/utils/version.py @@ -263,7 +263,6 @@ def _module_versions() -> Sequence[str]: ('jinja2', ['__version__']), ('pygments', ['__version__']), ('yaml', ['__version__']), - ('cssutils', ['__version__']), ('attr', ['__version__']), ('PyQt5.QtWebEngineWidgets', []), ('PyQt5.QtWebEngine', ['PYQT_WEBENGINE_VERSION_STR']), diff --git a/requirements.txt b/requirements.txt index ce4d80400..fee8906ae 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,6 @@ attrs==20.3.0 colorama==0.4.4 -cssutils==1.0.2 Jinja2==2.11.2 MarkupSafe==1.1.1 Pygments==2.7.2 diff --git a/scripts/dev/recompile_requirements.py b/scripts/dev/recompile_requirements.py index 00d95fe02..c63441047 100644 --- a/scripts/dev/recompile_requirements.py +++ b/scripts/dev/recompile_requirements.py @@ -164,7 +164,6 @@ CHANGELOG_URLS = { 'yamllint': 'https://github.com/adrienverge/yamllint/blob/master/CHANGELOG.rst', 'pathspec': 'https://github.com/cpburnz/python-path-specification/blob/master/CHANGES.rst', 'filelock': 'https://github.com/benediktschmitt/py-filelock/commits/master', - 'cssutils': 'https://pythonhosted.org/cssutils/CHANGELOG.html', 'github3.py': 'https://github3py.readthedocs.io/en/master/release-notes/index.html', 'manhole': 'https://github3py.readthedocs.io/en/master/release-notes/index.html', 'pycparser': 'https://github.com/eliben/pycparser/blob/master/CHANGES', diff --git a/tests/unit/browser/webkit/test_mhtml.py b/tests/unit/browser/webkit/test_mhtml.py index 1a2b6bf31..a30bfe786 100644 --- a/tests/unit/browser/webkit/test_mhtml.py +++ b/tests/unit/browser/webkit/test_mhtml.py @@ -28,12 +28,6 @@ import pytest mhtml = pytest.importorskip('qutebrowser.browser.webkit.mhtml') -try: - import cssutils -except ImportError: - cssutils = None - - @pytest.fixture(autouse=True) def patch_uuid(monkeypatch): monkeypatch.setattr(uuid, "uuid4", lambda: "UUID") @@ -255,34 +249,25 @@ def test_empty_content_type(checker): """) -@pytest.mark.parametrize('has_cssutils', [ - pytest.param(True, marks=pytest.mark.skipif( - cssutils is None, reason="requires cssutils"), id='with_cssutils'), - pytest.param(False, id='no_cssutils'), -]) -@pytest.mark.parametrize('inline, style, expected_urls', [ - pytest.param(False, "@import 'default.css'", ['default.css'], +@pytest.mark.parametrize('style, expected_urls', [ + pytest.param("@import 'default.css'", ['default.css'], id='import with apostrophe'), - pytest.param(False, '@import "default.css"', ['default.css'], + pytest.param('@import "default.css"', ['default.css'], id='import with quote'), - pytest.param(False, "@import \t 'tabbed.css'", ['tabbed.css'], + pytest.param("@import \t 'tabbed.css'", ['tabbed.css'], id='import with tab'), - pytest.param(False, "@import url('default.css')", ['default.css'], + pytest.param("@import url('default.css')", ['default.css'], id='import with url()'), - pytest.param(False, """body { + pytest.param("""body { background: url("/bg-img.png") }""", ['/bg-img.png'], id='background with body'), - pytest.param(True, 'background: url(folder/file.png) no-repeat', + pytest.param('background: url(folder/file.png) no-repeat', ['folder/file.png'], id='background'), - pytest.param(True, 'content: url()', [], id='content'), + pytest.param('content: url()', [], id='content'), ]) -def test_css_url_scanner(monkeypatch, has_cssutils, inline, style, - expected_urls): - if not has_cssutils: - monkeypatch.setattr(mhtml, '_get_css_imports_cssutils', - lambda data, inline=False: None) +def test_css_url_scanner(monkeypatch, style, expected_urls): expected_urls.sort() - urls = mhtml._get_css_imports(style, inline=inline) + urls = mhtml._get_css_imports(style) urls.sort() assert urls == expected_urls diff --git a/tests/unit/utils/test_version.py b/tests/unit/utils/test_version.py index 3393ae376..2bfdf10d7 100644 --- a/tests/unit/utils/test_version.py +++ b/tests/unit/utils/test_version.py @@ -561,7 +561,6 @@ class ImportFake: ('jinja2', True), ('pygments', True), ('yaml', True), - ('cssutils', True), ('attr', True), ('PyQt5.QtWebEngineWidgets', True), ('PyQt5.QtWebEngine', True), @@ -637,7 +636,6 @@ class TestModuleVersions: @pytest.mark.parametrize('module, idx, expected', [ ('colorama', 1, 'colorama: no'), - ('cssutils', 6, 'cssutils: no'), ]) def test_missing_module(self, module, idx, expected, import_fake): """Test with a module missing. @@ -681,7 +679,6 @@ class TestModuleVersions: ('jinja2', True), ('pygments', True), ('yaml', True), - ('cssutils', True), ('attr', True), ]) def test_existing_attributes(self, name, has_version): @@ -694,8 +691,6 @@ class TestModuleVersions: name: The name of the module to check. has_version: Whether a __version__ attribute is expected. """ - if name == 'cssutils': - pytest.importorskip(name) module = importlib.import_module(name) assert hasattr(module, '__version__') == has_version -- cgit v1.2.3-54-g00ecf