Error messages and explicit test for None
Error messages for validate() are more specific. Return of standarddir.conf() is explicitly tested for None to avoid ambiguity with other falsey values.
This commit is contained in:
parent
402aa66756
commit
de0686c50a
@ -805,7 +805,7 @@ class File(BaseType):
|
|||||||
value = os.path.expanduser(value)
|
value = os.path.expanduser(value)
|
||||||
value = os.path.expandvars(value)
|
value = os.path.expandvars(value)
|
||||||
if not os.path.isabs(value):
|
if not os.path.isabs(value):
|
||||||
if standarddir.config():
|
if standarddir.config() is not None:
|
||||||
abspath = os.path.join(standarddir.config(), value)
|
abspath = os.path.join(standarddir.config(), value)
|
||||||
if os.path.isfile(abspath):
|
if os.path.isfile(abspath):
|
||||||
return abspath
|
return abspath
|
||||||
@ -821,12 +821,16 @@ class File(BaseType):
|
|||||||
try:
|
try:
|
||||||
if not os.path.isabs(value):
|
if not os.path.isabs(value):
|
||||||
cfgdir = standarddir.config()
|
cfgdir = standarddir.config()
|
||||||
if cfgdir and os.path.isfile(os.path.join(cfgdir, value)):
|
if cfgdir is not None and os.path.isfile(
|
||||||
|
os.path.join(cfgdir, value)):
|
||||||
return
|
return
|
||||||
raise configexc.ValidationError(value,
|
raise configexc.ValidationError(
|
||||||
"must be an absolute path!")
|
value, "must be an absolute path when not using a config "
|
||||||
if not os.path.isfile(value):
|
"directory!")
|
||||||
raise configexc.ValidationError(value, "must be a valid file!")
|
elif not os.path.isfile(value):
|
||||||
|
raise configexc.ValidationError(
|
||||||
|
value, "must be a valid path relative to the config "
|
||||||
|
"directory!")
|
||||||
except UnicodeEncodeError as e:
|
except UnicodeEncodeError as e:
|
||||||
raise configexc.ValidationError(value, e)
|
raise configexc.ValidationError(value, e)
|
||||||
|
|
||||||
@ -1195,7 +1199,7 @@ class UserStyleSheet(File):
|
|||||||
raise configexc.ValidationError(value, str(e))
|
raise configexc.ValidationError(value, str(e))
|
||||||
return
|
return
|
||||||
except UnicodeEncodeError as e:
|
except UnicodeEncodeError as e:
|
||||||
raise configexc.ValidationError(value, e)
|
raise configexc.ValidationError(value, str(e))
|
||||||
|
|
||||||
|
|
||||||
class AutoSearch(BaseType):
|
class AutoSearch(BaseType):
|
||||||
|
Loading…
Reference in New Issue
Block a user