Revision 341ff8e9 lib/qlang.py

b/lib/qlang.py
1 1
#
2 2
#
3 3

  
4
# Copyright (C) 2010 Google Inc.
4
# Copyright (C) 2010, 2011 Google Inc.
5 5
#
6 6
# This program is free software; you can redistribute it and/or modify
7 7
# it under the terms of the GNU General Public License as published by
......
19 19
# 02110-1301, USA.
20 20

  
21 21

  
22
"""Module for a simple query language"""
22
"""Module for a simple query language
23

  
24
A query filter is always a list. The first item in the list is the operator
25
(e.g. C{[OP_AND, ...]}), while the other items depend on the operator. For
26
logic operators (e.g. L{OP_AND}, L{OP_OR}), they are subfilters whose results
27
are combined. Unary operators take exactly one other item (e.g. a subfilter for
28
L{OP_NOT} and a field name for L{OP_TRUE}). Binary operators take exactly two
29
operands, usually a field name and a value to compare against. Filters are
30
converted to callable functions by L{query._CompileFilter}.
31

  
32
"""
23 33

  
24 34
from ganeti import errors
25 35

  
26 36

  
27
# Logic operators
37
# Logic operators with one or more operands, each of which is a filter on its
38
# own
28 39
OP_OR = "|"
29 40
OP_AND = "&"
30 41

  
31 42

  
32
# Unary operators
43
# Unary operators with exactly one operand
33 44
OP_NOT = "!"
34 45
OP_TRUE = "?"
35 46

  
36 47

  
37
# Binary operators
48
# Binary operators with exactly two operands, the field name and an
49
# operator-specific value
38 50
OP_EQUAL = "="
39 51
OP_NOT_EQUAL = "!="
40 52
OP_GLOB = "=*"

Also available in: Unified diff