Skip to content
Snippets Groups Projects
Commit 53ede60d authored by Philipp Hörist's avatar Philipp Hörist
Browse files

CSSConfig: Fix pylint errors

parent 765180d1
No related branches found
No related tags found
No related merge requests found
......@@ -36,7 +36,8 @@
class CSSConfig():
def __init__(self):
"""CSSConfig handles loading and storing of all relevant Gajim style files
"""
CSSConfig handles loading and storing of all relevant Gajim style files
The order in which CSSConfig loads the styles
......@@ -138,14 +139,15 @@ def _load_css(self):
def _load_css_from_file(self, filename, priority):
path = os.path.join(configpaths.get('STYLE'), filename)
try:
with open(path, "r") as f:
css = f.read()
with open(path, "r") as file_:
css = file_.read()
except Exception as exc:
log.error('Error loading css: %s', exc)
return
self._activate_css(css, priority)
def _activate_css(self, css, priority):
@staticmethod
def _activate_css(css, priority):
try:
provider = Gtk.CssProvider()
provider.load_from_data(bytes(css.encode('utf-8')))
......@@ -247,7 +249,7 @@ def set_value(self, selector, attr, value, pre=False):
if not pre:
self._add_to_cache(selector, attr, value)
self._write(pre)
return
return None
# The rule was not found, so we add it to this theme
log.info('Set %s %s %s', selector, attr, value)
......@@ -255,6 +257,7 @@ def set_value(self, selector, attr, value, pre=False):
rule.style[attr] = value
css.add(rule)
self._write(pre)
return None
def set_font(self, selector, description, pre=False):
css = self._css
......@@ -297,13 +300,14 @@ def _get_attr_from_description(self, description):
family = description.get_family()
return family, size, style, weight
def _get_default_rule(self, selector, attr):
def _get_default_rule(self, selector, _attr):
for rule in self._default_css:
if rule.type != rule.STYLE_RULE:
continue
if rule.selectorText == selector:
log.info('Get Default Rule %s', selector)
return rule
return None
def get_font(self, selector, pre=False):
if pre:
......@@ -316,7 +320,7 @@ def get_font(self, selector, pre=False):
pass
if css is None:
return
return None
for rule in css:
if rule.type != rule.STYLE_RULE:
......@@ -335,10 +339,11 @@ def get_font(self, selector, pre=False):
return desc
self._add_to_cache(selector, 'fontdescription', None)
return None
def _get_description_from_css(self, family, size, style, weight):
if family is None:
return
return None
desc = Pango.FontDescription()
desc.set_family(family)
if weight is not None:
......@@ -403,6 +408,7 @@ def get_value(self, selector, attr, pre=False):
value = rule if rule is None else rule.style[attr]
self._add_to_cache(selector, attr, value)
return value
return None
def remove_value(self, selector, attr, pre=False):
if attr == StyleAttr.FONT:
......@@ -423,6 +429,7 @@ def remove_value(self, selector, attr, pre=False):
rule.style.removeProperty(attr)
break
self._write(pre)
return None
def remove_font(self, selector, pre=False):
css = self._css
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment