Compare commits
No commits in common. "eccc9a008de31324ad5a42cf2c9754388798a3bb" and "c8430f440e7b99002024fcabe59a7cbf90888c76" have entirely different histories.
eccc9a008d
...
c8430f440e
1 changed files with 0 additions and 65 deletions
65
bootstrap.py
65
bootstrap.py
|
|
@ -37,70 +37,6 @@ with open('servers.json', 'r') as server_fh:
|
||||||
MODULES = jsonfile['modules']
|
MODULES = jsonfile['modules']
|
||||||
|
|
||||||
|
|
||||||
async def set_linked_multi_variables(linked_server: str,
|
|
||||||
**kwargs: dict,
|
|
||||||
) -> None:
|
|
||||||
|
|
||||||
if linked_server is None:
|
|
||||||
return
|
|
||||||
if linked_server not in CONFIGS:
|
|
||||||
warn_explicit(ValueWarning(f'cannot find linked server "{linked_server}"'),
|
|
||||||
ValueWarning,
|
|
||||||
__file__,
|
|
||||||
0,
|
|
||||||
)
|
|
||||||
return
|
|
||||||
config = CONFIGS[linked_server][0]
|
|
||||||
dico = {}
|
|
||||||
variables = {}
|
|
||||||
for key, value in kwargs.items():
|
|
||||||
if value is None:
|
|
||||||
return
|
|
||||||
if key.startswith('linked_provider_'):
|
|
||||||
index = int(key[16])
|
|
||||||
path = await config.information.get('provider:' + value, None)
|
|
||||||
if not path:
|
|
||||||
return
|
|
||||||
if index not in variables:
|
|
||||||
variables[index] = {'path': None, 'value': None}
|
|
||||||
variables[index]['path'] = path
|
|
||||||
elif key.startswith('linked_value_'):
|
|
||||||
index = int(key[13])
|
|
||||||
if index not in variables:
|
|
||||||
variables[index] = {'path': None, 'value': None}
|
|
||||||
variables[index]['value'] = value
|
|
||||||
else:
|
|
||||||
raise AttributeError(f'unknown parameter {key}')
|
|
||||||
dynamic = None
|
|
||||||
slave_idx = None
|
|
||||||
await config.property.read_write()
|
|
||||||
try:
|
|
||||||
for index in sorted(list(variables)):
|
|
||||||
path = variables[index]['path']
|
|
||||||
value = variables[index]['value']
|
|
||||||
if dynamic:
|
|
||||||
path = path.replace('{suffix}', dynamic)
|
|
||||||
else:
|
|
||||||
dynamic = normalize_family(value)
|
|
||||||
option = config.forcepermissive.option(path, slave_idx)
|
|
||||||
multi = await option.option.ismulti()
|
|
||||||
if multi and await option.option.isfollower():
|
|
||||||
multi = await option.option.issubmulti()
|
|
||||||
if multi:
|
|
||||||
values = await option.value.get()
|
|
||||||
if value not in values:
|
|
||||||
values.append(value)
|
|
||||||
await option.value.set(values)
|
|
||||||
if await option.option.isleader():
|
|
||||||
slave_idx = values.index(value)
|
|
||||||
else:
|
|
||||||
await option.value.set(value)
|
|
||||||
except Exception as err:
|
|
||||||
await config.property.read_only()
|
|
||||||
raise err from err
|
|
||||||
await config.property.read_only()
|
|
||||||
|
|
||||||
|
|
||||||
async def set_linked(linked_server: str,
|
async def set_linked(linked_server: str,
|
||||||
linked_provider: str,
|
linked_provider: str,
|
||||||
linked_value: str,
|
linked_value: str,
|
||||||
|
|
@ -399,7 +335,6 @@ async def build(server_name, datas, module_infos):
|
||||||
cfg['extra_dictionaries'] = module_info.extra_dictionaries
|
cfg['extra_dictionaries'] = module_info.extra_dictionaries
|
||||||
cfg['extra_annotators'].append('risotto.rougail')
|
cfg['extra_annotators'].append('risotto.rougail')
|
||||||
optiondescription = {'set_linked': set_linked,
|
optiondescription = {'set_linked': set_linked,
|
||||||
'set_linked_multi_variables': set_linked_multi_variables,
|
|
||||||
'get_linked_configuration': get_linked_configuration,
|
'get_linked_configuration': get_linked_configuration,
|
||||||
'set_linked_configuration': set_linked_configuration,
|
'set_linked_configuration': set_linked_configuration,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue