Revision 03ec545a lib/qlang.py
b/lib/qlang.py | ||
---|---|---|
292 | 292 |
return [OP_EQUAL, namefield, text] |
293 | 293 |
|
294 | 294 |
|
295 |
def MakeFilter(args, force_filter): |
|
295 |
def MakeFilter(args, force_filter, namefield=None):
|
|
296 | 296 |
"""Try to make a filter from arguments to a command. |
297 | 297 |
|
298 | 298 |
If the name could be a filter it is parsed as such. If it's just a globbing |
... | ... | |
303 | 303 |
@param args: Arguments to command |
304 | 304 |
@type force_filter: bool |
305 | 305 |
@param force_filter: Whether to force treatment as a full-fledged filter |
306 |
@type namefield: string |
|
307 |
@param namefield: Name of field to use for simple filters (use L{None} for |
|
308 |
a default of "name") |
|
306 | 309 |
@rtype: list |
307 | 310 |
@return: Query filter |
308 | 311 |
|
309 | 312 |
""" |
313 |
if namefield is None: |
|
314 |
namefield = "name" |
|
315 |
|
|
310 | 316 |
if (force_filter or |
311 | 317 |
(args and len(args) == 1 and _CheckFilter(args[0]))): |
312 | 318 |
try: |
... | ... | |
317 | 323 |
|
318 | 324 |
result = ParseFilter(filter_text) |
319 | 325 |
elif args: |
320 |
result = [OP_OR] + map(compat.partial(_MakeFilterPart, "name"), args)
|
|
326 |
result = [OP_OR] + map(compat.partial(_MakeFilterPart, namefield), args)
|
|
321 | 327 |
else: |
322 | 328 |
result = None |
323 | 329 |
|
Also available in: Unified diff