From 2dcdbb137e73d3cfe91cf143325bd12b93c5148e Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 1 Oct 2013 08:19:10 +0200 Subject: [PATCH] rename FileOption to FilenameOption python 3 support --- test/test_config_api.py | 6 +++--- test/test_slots.py | 6 +++--- tiramisu/option.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/test_config_api.py b/test/test_config_api.py index c0cc9a7..f0681ea 100644 --- a/test/test_config_api.py +++ b/test/test_config_api.py @@ -4,7 +4,7 @@ from py.test import raises from tiramisu.config import Config from tiramisu.option import IntOption, FloatOption, StrOption, ChoiceOption, \ - BoolOption, FileOption, OptionDescription + BoolOption, FilenameOption, OptionDescription def make_description(): @@ -139,8 +139,8 @@ def test_does_not_find_in_config(): raises(AttributeError, "conf.find(byname='IDontExist')") -def test_file(): - a = FileOption('a', '') +def test_filename(): + a = FilenameOption('a', '') o = OptionDescription('o', '', [a]) c = Config(o) c.a = u'/' diff --git a/test/test_slots.py b/test/test_slots.py index 1f65f6d..2031cf8 100644 --- a/test/test_slots.py +++ b/test/test_slots.py @@ -6,7 +6,7 @@ from tiramisu.config import Config, SubConfig from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption,\ StrOption, SymLinkOption, UnicodeOption, IPOption, OptionDescription, \ PortOption, NetworkOption, NetmaskOption, DomainnameOption, EmailOption, \ - URLOption, FileOption + URLOption, FilenameOption def test_slots_option(): @@ -40,7 +40,7 @@ def test_slots_option(): raises(AttributeError, "c.x = 1") c = URLOption('a', '') raises(AttributeError, "c.x = 1") - c = FileOption('a', '') + c = FilenameOption('a', '') raises(AttributeError, "c.x = 1") @@ -58,7 +58,7 @@ def test_slots_option_readonly(): l = DomainnameOption('l', '') o = EmailOption('o', '') p = URLOption('p', '') - q = FileOption('q', '') + q = FilenameOption('q', '') m = OptionDescription('m', '', [a, b, c, d, e, g, h, i, j, k, l, o, p, q]) a._requires = 'a' b._requires = 'b' diff --git a/tiramisu/option.py b/tiramisu/option.py index 7dfe3d5..b894a74 100644 --- a/tiramisu/option.py +++ b/tiramisu/option.py @@ -425,7 +425,7 @@ class Option(BaseOption): self._validate(_value) except ValueError as err: raise ValueError(_('invalid value for option {0}: {1}' - '').format(self._name, err.message)) + '').format(self._name, err)) try: # valid with self._validator val_validator(_value) @@ -435,7 +435,7 @@ class Option(BaseOption): self._second_level_validation(_value) except ValueError as err: msg = _("invalid value for option {0}: {1}").format( - self._name, err.message) + self._name, err) if self._warnings_only: warnings.warn_explicit(ValueWarning(msg, self), ValueWarning, @@ -1096,7 +1096,7 @@ class URLOption(DomainnameOption): raise ValueError(_('invalid url, should ends with filename')) -class FileOption(Option): +class FilenameOption(Option): __slots__ = tuple() _opt_type = 'file' path_re = re.compile(r"^[a-zA-Z0-9\-\._~/+]+$")