@@ -153,47 +153,51 @@ class {{ k.name }}({{ parent }}):
153
153
{ { line } }
154
154
{% endfor %}
155
155
{% if k.args %}
156
- {% if k.docstring %}
156
+ {% if k.docstring %}
157
157
158
- {% endif %}
159
- {% for kwarg in k.args %}
160
- {% for line in kwarg.doc %}
158
+ {% endif %}
159
+ {% for kwarg in k.args %}
160
+ {% for line in kwarg.doc %}
161
161
{ { line } }
162
- {% endfor %}
163
- {% endfor %}
162
+ {% endfor %}
163
+ {% endfor %}
164
164
{% endif %}
165
165
"""
166
166
name = "{ { k.property_name } }"
167
167
{% if k.params %}
168
168
_param_defs = {
169
- {% for param in k.params %}
169
+ {% for param in k.params %}
170
170
"{ { param.name } }": { { param.param } },
171
- {% endfor %}
172
- {% if k.name == " FunctionScore" %}
171
+ {% endfor %}
172
+ {% if k.name == " FunctionScore" %}
173
+ { # The FunctionScore class implements a custom solution for the `functions`
174
+ shortcut property. Until the code generator can support shortcut
175
+ properties directly that solution is added here #}
173
176
"filter": { " type" : " query" } ,
174
177
"functions": { " type" : " score_function" , " multi" : True} ,
175
- {% endif %}
178
+ {% endif %}
176
179
}
177
180
{% endif %}
178
181
179
182
def __init__(
180
183
self,
181
184
{% for arg in k.args %}
182
- {% if arg.positional %}
185
+ {% if arg.positional %}
183
186
{ { arg.name } }: { { arg.type } } = DEFAULT,
184
- {% endif %}
187
+ {% endif %}
185
188
{% endfor %}
186
189
{% if k.args and not k.args[-1].positional %}
187
190
*,
188
191
{% endif %}
189
192
{% for arg in k.args %}
190
- {% if not arg.positional %}
193
+ {% if not arg.positional %}
191
194
{ { arg.name } }: { { arg.type } } = DEFAULT,
192
- {% endif %}
195
+ {% endif %}
193
196
{% endfor %}
194
197
**kwargs: Any
195
198
):
196
199
{% if k.name == " FunctionScore" %}
200
+ { # continuation of the FunctionScore shortcut property support from above #}
197
201
if functions is DEFAULT:
198
202
functions = []
199
203
for name in ScoreFunction._classes:
@@ -209,13 +213,15 @@ class {{ k.name }}({{ parent }}):
209
213
{% endif %}
210
214
super().__init__(
211
215
{% for arg in k.args %}
212
- {% if not arg.positional %}
216
+ {% if not arg.positional %}
213
217
{ { arg.name } }={ { arg.name } },
214
- {% endif %}
218
+ {% endif %}
215
219
{% endfor %}
216
220
**kwargs
217
221
)
218
222
223
+ { # what follows is a set of Pythonic enhancements to some of the query classes
224
+ which are outside the scope of the code generator #}
219
225
{% if k.name == " MatchAll" %}
220
226
def __add__(self, other: "Query") -> "Query":
221
227
return other._clone()
0 commit comments