]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
python: move Validator base class and ValidationError to getopt
authorRob van der Linde <rob@catalyst.net.nz>
Thu, 5 Oct 2023 01:30:20 +0000 (14:30 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 24 Oct 2023 23:31:29 +0000 (23:31 +0000)
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>
python/samba/getopt.py
python/samba/netcmd/validators.py

index ea1f338d04c6aac26287e478b414b3c0b192530e..04cae4cce784521367c2b807eeb296fe39e85850 100644 (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",)
index c8c5697d23fb675c7b6bf65c05661ad61985d7b9..5690341df5b069e8caff9e2a5c809c5208c18c41 100644 (file)
 # 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):