From 9a818ab40be85c0d2ae9a700edc814767bb2949e Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Thu, 24 Apr 2025 11:08:34 +0200 Subject: [PATCH] revert 'change to new visibility spec' nicos is not yet ready for this Change-Id: Ibfbb7e32e06a6e0616ded8342bc5844fd531944f --- frappy/datatypes.py | 10 ---------- frappy/modulebase.py | 10 +++++----- frappy/params.py | 10 +++++----- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/frappy/datatypes.py b/frappy/datatypes.py index 0c47506..1bac6ee 100644 --- a/frappy/datatypes.py +++ b/frappy/datatypes.py @@ -1238,16 +1238,6 @@ class OrType(DataType): raise WrongTypeError(f"Invalid Value, must conform to one of {', '.join(str(t) for t in self.types)}") -LEGACY_VISIBILITY = {'user': 'www', 1: 'www', 'advanced': 'ww-', 2: 'ww-', 'expert': 'w--', 3: 'w--'} - - -def visibility_validator(value): - value = LEGACY_VISIBILITY.get(value, value) - if len(value) == 3 and set(value) <= set('wr-'): - return value - raise RangeError(f'{value!r} is not a valid visibility') - - Int8 = IntRange(-(1 << 7), (1 << 7) - 1) Int16 = IntRange(-(1 << 15), (1 << 15) - 1) Int32 = IntRange(-(1 << 31), (1 << 31) - 1) diff --git a/frappy/modulebase.py b/frappy/modulebase.py index 4263438..9a034f0 100644 --- a/frappy/modulebase.py +++ b/frappy/modulebase.py @@ -27,9 +27,9 @@ import time import threading from collections import OrderedDict -from frappy.datatypes import ArrayOf, BoolType, FloatRange, IntRange, NoneOr, \ - StringType, TextType, TupleOf, ValueType, visibility_validator - +from frappy.datatypes import ArrayOf, BoolType, EnumType, FloatRange, \ + IntRange, StringType, TextType, TupleOf, \ + NoneOr from frappy.errors import BadValueError, CommunicationFailedError, ConfigError, \ ProgrammingError, SECoPError, secop_error, RangeError from frappy.lib import formatException, mkthread, UniqueObject @@ -306,8 +306,8 @@ class Module(HasAccessibles): description = Property('description of the module', TextType(), extname='description', mandatory=True) meaning = Property('optional meaning indicator', TupleOf(StringType(), IntRange(0, 50)), default=('', 0), extname='meaning') - visibility = Property('optional visibility hint', ValueType(visibility_validator), - default='www', extname='visibility') + visibility = Property('optional visibility hint', EnumType('visibility', user=1, advanced=2, expert=3), + default='user', extname='visibility') implementation = Property('internal name of the implementation class of the module', StringType(), extname='implementation') interface_classes = Property('offical highest interface-class of the module', ArrayOf(StringType()), diff --git a/frappy/params.py b/frappy/params.py index 8e27e6d..c649ab9 100644 --- a/frappy/params.py +++ b/frappy/params.py @@ -26,7 +26,7 @@ import inspect from frappy.datatypes import ArrayOf, BoolType, CommandType, DataType, \ DataTypeType, EnumType, FloatRange, NoneOr, OrType, StringType, StructOf, \ - TextType, TupleOf, ValueType, visibility_validator + TextType, TupleOf, ValueType from frappy.errors import BadValueError, ProgrammingError, WrongTypeError from frappy.lib import generalConfig from frappy.properties import HasProperties, Property @@ -152,8 +152,8 @@ class Parameter(Accessible): 'optional parameter group this parameter belongs to', StringType(), extname='group', default='') visibility = Property( - 'optional visibility hint', ValueType(visibility_validator), - extname='visibility', default='www') + 'optional visibility hint', EnumType('visibility', user=1, advanced=2, expert=3), + extname='visibility', default=1) constant = Property( 'optional constant value for constant parameters', ValueType(), extname='constant', default=None) @@ -367,8 +367,8 @@ class Command(Accessible): 'optional command group of the command.', StringType(), extname='group', export=True, default='') visibility = Property( - 'optional visibility hint', ValueType(visibility_validator), - extname='visibility', export=True, default='www') + 'optional visibility hint', EnumType('visibility', user=1, advanced=2, expert=3), + extname='visibility', export=True, default=1) export = Property( '''[internal] export settings