1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-12 12:23:50 +03:00

python: move Validator base class and ValidationError to getopt

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>
This commit is contained in:
Rob van der Linde
2023-10-05 14:30:20 +13:00
committed by Andrew Bartlett
parent 29c9991594
commit dc513a82a6
2 changed files with 13 additions and 12 deletions

View File

@@ -22,6 +22,7 @@ __docformat__ = "restructuredText"
import optparse
import os
import sys
from abc import ABCMeta, abstractmethod
from copy import copy
from samba.credentials import (
@@ -74,6 +75,17 @@ def check_bytes(option, opt, value):
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",)