It makes more sense for these to exist in the top package, because they are used by SambaOption.
validators.py can still exist in netcmd, just not the base class and exception.
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
import optparse
import os
import sys
+from abc import ABCMeta, abstractmethod
from copy import copy
from samba.credentials import (
raise optparse.OptionValueError(msg)
+class ValidationError(Exception):
+ pass
+
+
+class Validator(metaclass=ABCMeta):
+
+ @abstractmethod
+ def __call__(self, field, value):
+ pass
+
+
class SambaOption(optparse.Option):
ATTRS = optparse.Option.ATTRS + ["validators"]
TYPES = optparse.Option.TYPES + ("bytes",)
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-from abc import ABCMeta, abstractmethod
-
-
-class ValidationError(Exception):
- pass
-
-
-class Validator(metaclass=ABCMeta):
-
- @abstractmethod
- def __call__(self, field, value):
- pass
+from samba.getopt import Validator, ValidationError
class Range(Validator):