@@ -129,11 +129,13 @@ def _list_settings(
129
129
extension = ".json" ,
130
130
labextensions_path = None ,
131
131
translator = None ,
132
+ ids_only = False ,
132
133
):
133
134
"""
134
135
Returns a tuple containing:
135
136
- the list of plugins, schemas, and their settings,
136
- respecting any defaults that may have been overridden.
137
+ respecting any defaults that may have been overridden if `ids_only=False`,
138
+ otherwise a list of dict containing only the ids of plugins.
137
139
- the list of warnings that were generated when
138
140
validating the user overrides against the schemas.
139
141
"""
@@ -159,16 +161,20 @@ def _list_settings(
159
161
).replace (
160
162
"\\ " , "/"
161
163
) # Normalize slashes.
162
- schema , version = _get_schema (schemas_dir , schema_name , overrides , None )
163
- if translator is not None :
164
- schema = translator (schema )
165
- user_settings = _get_user_settings (settings_dir , schema_name , schema )
166
164
167
- if user_settings ["warning" ]:
168
- warnings .append (user_settings .pop ("warning" ))
165
+ if ids_only :
166
+ settings [_id ] = dict (id = _id )
167
+ else :
168
+ schema , version = _get_schema (schemas_dir , schema_name , overrides , None )
169
+ if translator is not None :
170
+ schema = translator (schema )
171
+ user_settings = _get_user_settings (settings_dir , schema_name , schema )
172
+
173
+ if user_settings ["warning" ]:
174
+ warnings .append (user_settings .pop ("warning" ))
169
175
170
- # Add the plugin to the list of settings.
171
- settings [_id ] = dict (id = _id , schema = schema , version = version , ** user_settings )
176
+ # Add the plugin to the list of settings.
177
+ settings [_id ] = dict (id = _id , schema = schema , version = version , ** user_settings )
172
178
173
179
if labextensions_path is not None :
174
180
schema_paths = []
@@ -195,16 +201,21 @@ def _list_settings(
195
201
if _id in federated_settings :
196
202
continue
197
203
198
- schema , version = _get_schema (
199
- schemas_dir , schema_name , overrides , labextensions_path = labextensions_path
200
- )
201
- user_settings = _get_user_settings (settings_dir , schema_name , schema )
204
+ if ids_only :
205
+ federated_settings [_id ] = dict (id = _id )
206
+ else :
207
+ schema , version = _get_schema (
208
+ schemas_dir , schema_name , overrides , labextensions_path = labextensions_path
209
+ )
210
+ user_settings = _get_user_settings (settings_dir , schema_name , schema )
202
211
203
- if user_settings ["warning" ]:
204
- warnings .append (user_settings .pop ("warning" ))
212
+ if user_settings ["warning" ]:
213
+ warnings .append (user_settings .pop ("warning" ))
205
214
206
- # Add the plugin to the list of settings.
207
- federated_settings [_id ] = dict (id = _id , schema = schema , version = version , ** user_settings )
215
+ # Add the plugin to the list of settings.
216
+ federated_settings [_id ] = dict (
217
+ id = _id , schema = schema , version = version , ** user_settings
218
+ )
208
219
209
220
settings .update (federated_settings )
210
221
settings_list = [settings [key ] for key in sorted (settings .keys (), reverse = True )]
@@ -317,6 +328,7 @@ def get_settings(
317
328
overrides = None ,
318
329
labextensions_path = None ,
319
330
translator = None ,
331
+ ids_only = False ,
320
332
):
321
333
"""
322
334
Get settings.
@@ -343,9 +355,10 @@ def get_settings(
343
355
-------
344
356
tuple
345
357
The first item is a dictionary with a list of setting if no `schema_name`
346
- was provided, otherwise it is a dictionary with id, raw, scheme, settings
347
- and version keys. The second item is a list of warnings. Warnings will
348
- either be a list of i) strings with the warning messages or ii) `None`.
358
+ was provided (only the ids if `ids_only=True`), otherwise it is a dictionary
359
+ with id, raw, scheme, settings and version keys.
360
+ The second item is a list of warnings. Warnings will either be a list of
361
+ i) strings with the warning messages or ii) `None`.
349
362
"""
350
363
result = {}
351
364
warnings = []
@@ -367,6 +380,7 @@ def get_settings(
367
380
overrides ,
368
381
labextensions_path = labextensions_path ,
369
382
translator = translator ,
383
+ ids_only = ids_only ,
370
384
)
371
385
result = {
372
386
"settings" : settings_list ,
0 commit comments