Skip to content

Commit d71fbcb

Browse files
committed
[IMP] controller_report_xls: Apply pre-commit-vauxoo fixes
- Fix undefined variable 'cssstyle' in get_css_style function - Fix undefined variable 'result' in match_color_index function - Improve string comparison using truthiness instead of empty string check
1 parent 3f8a0c4 commit d71fbcb

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

controller_report_xls/controllers/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def get_css_style(csstext, style):
1919
cssutils.log.setLevel(logging.CRITICAL)
2020
cssnode = parseString(csstext)
2121
stylesheet = cssnode.cssRules
22+
cssstyle = None
2223
for rule in stylesheet:
2324
if rule.selectorText.replace(".", "") == style:
2425
cssstyle = str(rule.style.cssText)
@@ -30,9 +31,9 @@ def get_odoo_style(html, style, node):
3031
for class_style in node.attrib.get("class", False).split():
3132
for style_element in html.xpath('//style[@type="text/css"]'):
3233
styleclass = get_css_style(style_element.text, class_style)
33-
style.update(dict(item.split(":") for item in text_adapt(styleclass).split(";") if item != ""))
34+
style.update(dict(item.split(":") for item in text_adapt(styleclass).split(";") if item))
3435
if node.attrib.get("style", False):
35-
style.update(dict(item.split(":") for item in node.attrib.get("style").split(";") if item != ""))
36+
style.update(dict(item.split(":") for item in node.attrib.get("style").split(";") if item))
3637
return style
3738

3839

controller_report_xls/reports/report_xls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def get_odoo_style(html, style, node):
3131
for class_style in node.attrib.get("class", False).split():
3232
for style_element in html.xpath('//style[@type="text/css"]'):
3333
styleclass = get_css_style(style_element.text, class_style)
34-
style.update(dict(item.split(":") for item in text_adapt(styleclass).split(";") if item != ""))
34+
style.update(dict(item.split(":") for item in text_adapt(styleclass).split(";") if item))
3535
if node.attrib.get("style", False):
3636
style_nodes = [style_node.strip() for style_node in node.attrib.get("style").split(";") if style_node.strip()]
3737
style.update(dict(item.split(":", 1) for item in style_nodes))

controller_report_xls/reports/xfstyle.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ def match_color_index(color):
260260
color = htmlcolortorgb(color)
261261
if isinstance(color, int):
262262
return color
263+
result = None
263264
if color:
264265
distances = [color_distance(color, x) for x in XLWT_COLORS]
265266
result = distances.index(min(distances))

0 commit comments

Comments
 (0)