update 2023-05-30 from gitmlz

Change-Id: I0b1eb2941692fde5c9d98f107fc38315625dcfdb
This commit is contained in:
2023-05-31 14:16:12 +02:00
parent 726665ebd8
commit c5d429346d
8 changed files with 111 additions and 11 deletions

View File

@@ -22,10 +22,12 @@
import os
import re
from collections import Counter
from frappy.errors import ConfigError
from frappy.lib import generalConfig
class Undef:
pass
@@ -126,7 +128,7 @@ class Config(dict):
self.modules.append(mod)
def process_file(filename):
def process_file(filename, log):
with open(filename, 'rb') as f:
config_text = f.read()
node = NodeCollector()
@@ -135,6 +137,13 @@ def process_file(filename):
# pylint: disable=exec-used
exec(compile(config_text, filename, 'exec'), ns)
# check for duplicates in the file itself. Between files comes later
duplicates = [name for name, count in Counter([mod['name']
for mod in mods.list]).items() if count > 1]
if duplicates:
log.warning('Duplicate module name in file \'%s\': %s',
filename, ','.join(duplicates))
return Config(node, mods)
@@ -177,7 +186,7 @@ def load_config(cfgfiles, log):
for cfgfile in cfgfiles.split(','):
filename = to_config_path(cfgfile, log)
log.debug('Parsing config file %s...', filename)
cfg = process_file(filename)
cfg = process_file(filename, log)
if config:
config.merge_modules(cfg)
else:

View File

@@ -405,8 +405,4 @@ def merge_status(*args):
texts matching maximal code are joined with ', '
"""
maxcode = max(a[0] for a in args)
# take status value matching highest status code
merged = [a[1] for a in args if a[0] == maxcode and a[1]]
# merge the split texts. use dict instead of set for keeping order
merged = {m: 0 for mm in merged for m in mm.split(', ')}
return maxcode, ', '.join(merged)
return maxcode, ', '.join([a[1] for a in args if a[0] == maxcode and a[1]])

View File

@@ -27,7 +27,7 @@ import inspect
from frappy.datatypes import BoolType, CommandType, DataType, \
DataTypeType, EnumType, NoneOr, OrType, FloatRange, \
StringType, StructOf, TextType, TupleOf, ValueType
StringType, StructOf, TextType, TupleOf, ValueType, ArrayOf
from frappy.errors import BadValueError, WrongTypeError, ProgrammingError
from frappy.properties import HasProperties, Property
from frappy.lib import generalConfig
@@ -168,6 +168,9 @@ class Parameter(Accessible):
or the minimum time between updates of equal values [sec]''',
OrType(FloatRange(0), EnumType(always=0, never=999999999, default=-1)),
export=False, default=-1)
influences = Property(
'optional hint about effected parameters', ArrayOf(StringType()),
extname='influences', export=True, mandatory=False, default=[])
# used on the instance copy only
# value = None
@@ -363,6 +366,9 @@ class Command(Accessible):
result = Property(
'datatype of the result from the command, or None', NoneOr(DataTypeType()),
export=False, mandatory=True)
influences = Property(
'optional hint about effected parameters', ArrayOf(StringType()),
extname='influences', export=True, mandatory=False, default=[])
func = None