forked from pool/python-qstylizer
Accepting request 888200 from home:bnavigator:branches:devel:languages:python
- fix bug in qstylizer-tinycss2.patch gh#blambright/qstylizer#10 so that spyder does not look as ugly OBS-URL: https://build.opensuse.org/request/show/888200 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-qstylizer?expand=0&rev=5
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Sat Apr 24 13:04:07 UTC 2021 - Ben Greiner <code@bnavigator.de>
|
||||||
|
|
||||||
|
- fix bug in qstylizer-tinycss2.patch gh#blambright/qstylizer#10
|
||||||
|
so that spyder does not look as ugly
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Mon Apr 19 16:22:54 UTC 2021 - Ben Greiner <code@bnavigator.de>
|
Mon Apr 19 16:22:54 UTC 2021 - Ben Greiner <code@bnavigator.de>
|
||||||
|
|
||||||
|
@@ -1,18 +1,8 @@
|
|||||||
From 9228896f335cd6519a8abab70c8c0e38b6a28267 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Ben Greiner <code@bnavigator.de>
|
|
||||||
Date: Thu, 8 Apr 2021 21:15:03 +0200
|
|
||||||
Subject: [PATCH] use tinycss2 instead of tinycss
|
|
||||||
|
|
||||||
---
|
|
||||||
qstylizer/parser.py | 45 ++++++++++++++++++++++++++++-----------------
|
|
||||||
requirements.txt | 2 +-
|
|
||||||
2 files changed, 29 insertions(+), 18 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/qstylizer/parser.py b/qstylizer/parser.py
|
diff --git a/qstylizer/parser.py b/qstylizer/parser.py
|
||||||
index 71864af..635e01e 100644
|
index 71864af..d276727 100644
|
||||||
--- a/qstylizer/parser.py
|
--- a/qstylizer/parser.py
|
||||||
+++ b/qstylizer/parser.py
|
+++ b/qstylizer/parser.py
|
||||||
@@ -1,32 +1,43 @@
|
@@ -1,32 +1,29 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
-from tinycss.css21 import CSS21Parser
|
-from tinycss.css21 import CSS21Parser
|
||||||
@@ -29,18 +19,8 @@ index 71864af..635e01e 100644
|
|||||||
- if name.startswith("qproperty-"):
|
- if name.startswith("qproperty-"):
|
||||||
- declaration.name = name
|
- declaration.name = name
|
||||||
- return declaration
|
- return declaration
|
||||||
+def _strip_whitespace_recursive(value):
|
-
|
||||||
+ for i, v in enumerate(value):
|
-
|
||||||
+ if isinstance(v, list):
|
|
||||||
+ value[i].value = _strip_whitespace_recursive(v)
|
|
||||||
+ else:
|
|
||||||
+ try:
|
|
||||||
+ value[i].value = v.value.strip()
|
|
||||||
+ except AttributeError:
|
|
||||||
+ pass
|
|
||||||
+ return value
|
|
||||||
|
|
||||||
|
|
||||||
def parse(stylesheet):
|
def parse(stylesheet):
|
||||||
- """Parse a stylesheet using tinycss and return a StyleSheet instance.
|
- """Parse a stylesheet using tinycss and return a StyleSheet instance.
|
||||||
+ """Parse a stylesheet using tinycss2 and return a StyleSheet instance.
|
+ """Parse a stylesheet using tinycss2 and return a StyleSheet instance.
|
||||||
@@ -62,16 +42,14 @@ index 71864af..635e01e 100644
|
|||||||
+ for node in parsed_stylesheet:
|
+ for node in parsed_stylesheet:
|
||||||
+ if node.type == "error":
|
+ if node.type == "error":
|
||||||
+ raise ValueError("Cannot parse Stylesheet: " + node.message)
|
+ raise ValueError("Cannot parse Stylesheet: " + node.message)
|
||||||
+ selector = tinycss2.serialize(_strip_whitespace_recursive(node.prelude))
|
+ selector = tinycss2.serialize(node.prelude).strip()
|
||||||
+ declaration_list = tinycss2.parse_declaration_list(
|
+ declaration_list = tinycss2.parse_declaration_list(
|
||||||
+ node.content, skip_comments=True, skip_whitespace=True
|
+ node.content, skip_comments=True, skip_whitespace=True
|
||||||
+ )
|
+ )
|
||||||
+ for declaration in declaration_list:
|
+ for declaration in declaration_list:
|
||||||
+ if declaration.type == "declaration":
|
+ if declaration.type == "declaration":
|
||||||
+ prop = declaration.name.strip()
|
+ prop = declaration.name.strip()
|
||||||
+ v = _strip_whitespace_recursive(declaration.value)
|
+ css[selector][prop] = tinycss2.serialize(declaration.value).strip()
|
||||||
+ value = tinycss2.serialize(v)
|
|
||||||
+ css[selector][prop] = value
|
|
||||||
return css
|
return css
|
||||||
diff --git a/requirements.txt b/requirements.txt
|
diff --git a/requirements.txt b/requirements.txt
|
||||||
index 46f1d65..d56a026 100644
|
index 46f1d65..d56a026 100644
|
||||||
|
Reference in New Issue
Block a user