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

Function output_members

tools/fromschema.py:125–205  ·  view source on GitHub ↗

Generate lines for these properties

(sub, indent='')

Source from the content-addressed store, hash-verified

123
124
125def output_members(sub, indent=''):
126 """Generate lines for these properties"""
127 warnings = []
128
129 # Remove deprecated and stub properties, collect warnings
130 # (Stubs required to keep additionalProperties: false happy)
131
132 # FIXME: It fails for schemas which have only an array type with
133 # no properties, ex:
134 # "abcd": {
135 # "type": "array",
136 # "items": {
137 # "type": "whatever",
138 # "description": "efgh"
139 # }
140 # }
141 # Checkout the schema of `staticbackup`.
142 for p in list(sub['properties'].keys()):
143 if len(sub['properties'][p]) == 0 or 'deprecated' in sub['properties'][p]:
144 del sub['properties'][p]
145 elif p.startswith('warning'):
146 warnings.append(p)
147
148 # First list always-present properties
149 for p in sub['properties']:
150 if p.startswith('warning'):
151 continue
152 if 'required' in sub and p in sub['required']:
153 output_member(p, sub['properties'][p], False, indent)
154
155 for p in sub['properties']:
156 if p.startswith('warning'):
157 continue
158 if 'required' not in sub or p not in sub['required']:
159 output_member(p, sub['properties'][p], True, indent)
160
161 if warnings != []:
162 output(indent + "- the following warnings are possible:\n")
163 for w in warnings:
164 output_member(w, sub['properties'][w], False, indent + ' ', print_type=False)
165
166 # Not handled.
167 assert 'oneOf' not in sub
168
169 # If we have multiple ifs, we have to wrap them in allOf.
170 if 'allOf' in sub:
171 ifclauses = sub['allOf']
172 elif 'if' in sub:
173 ifclauses = [sub]
174 else:
175 ifclauses = []
176
177 # We partially handle if, assuming it depends on particular values of prior properties.
178 for ifclause in ifclauses:
179 conditions = []
180
181 # "required" are fields that simply must be present
182 for r in ifclause['if'].get('required', []):

Callers 3

output_memberFunction · 0.85
output_arrayFunction · 0.85
generate_from_schemaFunction · 0.85

Calls 8

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

Tested by

no test coverage detected