MCPcopy Create free account
hub / github.com/ElementsProject/lightning / output_members

Function output_members

tools/fromschema.py:234–315  ·  view source on GitHub ↗

Generate lines for these properties

(sub, indent='')

Source from the content-addressed store, hash-verified

232
233
234def output_members(sub, indent=''):
235 """Generate lines for these properties"""
236 warnings = []
237 if 'properties' in sub:
238 for p in list(sub['properties'].keys()):
239 if len(sub['properties'][p]) == 0 or sub['properties'][p].get('deprecated') is True:
240 del sub['properties'][p]
241 elif p.startswith('warning'):
242 warnings.append(p)
243
244 # First list always-present properties
245 for p in sub['properties']:
246 if p.startswith('warning'):
247 continue
248 if 'required' in sub and p in sub['required']:
249 output_member(p, sub['properties'][p], False, indent)
250
251 for p in sub['properties']:
252 if p.startswith('warning'):
253 continue
254 if 'required' not in sub or p not in sub['required']:
255 output_member(p, sub['properties'][p], True, indent)
256
257 if warnings != []:
258 output(indent + '- the following warnings are possible:\n')
259 for w in warnings:
260 output_member(w, sub['properties'][w], False, indent + ' ', print_type=False)
261
262 if 'oneOf' in sub:
263 for oneOfItem in sub['oneOf']:
264 if 'properties' not in oneOfItem and 'type' not in oneOfItem:
265 continue
266
267 if oneOfItem.get('type') == 'array':
268 output_array(oneOfItem, indent)
269 elif 'properties' in oneOfItem:
270 output_members(oneOfItem, indent)
271 else:
272 output_member(
273 None,
274 oneOfItem,
275 False,
276 indent,
277 False if 'enum' in oneOfItem else True
278 )
279
280 # If we have multiple ifs, we have to wrap them in allOf.
281 if 'allOf' in sub:
282 ifclauses = sub['allOf']
283 elif 'if' in sub:
284 ifclauses = [sub]
285 else:
286 ifclauses = []
287
288 # We partially handle if, assuming it depends on particular values of prior properties.
289 for ifclause in ifclauses:
290 conditions = []
291

Callers 4

output_memberFunction · 0.85
output_arrayFunction · 0.85
generate_descriptionFunction · 0.85
generate_return_valueFunction · 0.85

Calls 9

output_memberFunction · 0.85
outputFunction · 0.85
output_arrayFunction · 0.85
fmt_propnameFunction · 0.85
json_valueFunction · 0.85
has_membersFunction · 0.85
outputsFunction · 0.85
joinMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected