From 61f32b3e9b693895f2fad4f44122bcb6bb161dba Mon Sep 17 00:00:00 2001 From: Lamar Pavel Date: Fri, 22 May 2015 18:40:56 +0200 Subject: [PATCH] Revert some changes, trying to get rid of the tox failures --- qutebrowser/config/configtypes.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py index a1cf77561..a9d73d454 100644 --- a/qutebrowser/config/configtypes.py +++ b/qutebrowser/config/configtypes.py @@ -1152,20 +1152,16 @@ class UserStyleSheet(File): def __init__(self): super().__init__(none_ok=True) - def relapath(self, path): - path = os.path.expandvars(path) + def transform(self, value): + if not value: + return None + path = os.path.expandvars(value) path = os.path.expanduser(path) if not os.path.isabs(path): abspath = os.path.join(standarddir.config(), path) if os.path.isfile(abspath): - return abspath - return path - - def transform(self, value): - path = self.relapath(value) - if not value: - return None - elif os.path.isabs(path): + path = abspath + if os.path.isabs(path): return QUrl.fromLocalFile(path) else: data = base64.b64encode(value.encode('utf-8')).decode('ascii') @@ -1177,7 +1173,12 @@ class UserStyleSheet(File): return else: raise configexc.ValidationError(value, "may not be empty!") - value = self.relapath(value) + value = os.path.expandvars(value) + value = os.path.expanduser(value) + if not os.path.isabs(value): + abspath = os.path.join(standarddir.config(), value) + if os.path.isfile(abspath): + value = abspath try: if not os.path.isabs(value): # probably a CSS, so we don't handle it as filename.