specs_matcher¶
- oslo_utils.specs_matcher.make_grammar()¶
Creates the grammar to be used by a spec matcher.
The grammar created supports the following operations.
- Numerical values:
= :
equal to or greater than. This is equivalent to>=
and is supported for legacy reasons!= :
Float/integer value not equal<= :
Float/integer value less than or equal< :
Float/integer value less than== :
Float/integer value equal>= :
Float/integer value greater than or equal> :
Float/integer value greater
- String operations:
s!= :
Not equals< :
Less thans<= :
Less than or equals== :
Equals> :
Greater thans>= :
Greater than or equal
- Other operations:
<all-in> :
All items ‘in’ value<in> :
Item ‘in’ value, like a substring in a string.<or> :
Logical ‘or’
If no operator is specified the default is
s==
(string equality comparison)- Example operations:
">= 60"
Is the numerical value greater than or equal to 60"<or> spam <or> eggs"
Does the value containspam
oreggs
"s== 2.1.0"
Is the string value equal to2.1.0
"<in> gcc"
Is the stringgcc
contained in the value string"<all-in> aes mmx"
Are bothaes
andmmx
in the value
- Returns
A pyparsing.MatchFirst object. See https://pythonhosted.org/pyparsing/ for details on pyparsing.
- oslo_utils.specs_matcher.match(cmp_value, spec)¶
Match a given value to a given spec DSL.
This uses the grammar defined by make_grammar()
- Parameters
cmp_value – Value to be checked for match.
spec – The comparison specification string, for example
">= 70"
or"s== string_value"
. Seemake_grammar()
for examples of a specification string.
- Returns
True if cmp_value is a match for spec. False otherwise.