Trees | Indices | Help |
|
---|
|
pywurfl Query Language
pywurfl QL is a WURFL query language that looks very similar to SQL.
The select statement consists of the keyword 'select' followed by the select type which can be one of these keywords: 'device', 'ua', 'id'. The select statement is the first statement in all queries.
When 'select' is followed by the keyword 'device', a device object will be returned for each device that matches the 'where' expression (see below).
When 'select' is followed by the keyword 'ua', an user-agent string will be returned for each device that matches the 'where' expression (see below).
When 'select' is followed by the keyword 'id', a WURFL id string will be returned for each device that matches the 'where' expression (see below).
The where statement follows a select statement and can consist of the following elements: 'where condition', 'any statement', 'all statement'.
A where condition consists of a capability name followed by a test operator followed by a value. For example, "ringtone = true".
An any statement consists of the keyword 'any' followed by a parenthesized, comma delimited list of capability names, followed by a test operator and then followed by a value. All capabilities listed in an any statement will be 'ored' together. There must be a minimum of two capabilities listed.
For example: "any(ringtone_mp3, ringtone_wav) = true".
An all statement consists of the keyword 'all' followed by a parenthesized, comma delimited list of capability names, followed by a test operator and then followed by a value. All capabilities listed in an all statement will be 'anded' together. There must be a minimum of two capabilities listed.
For example: "all(ringtone_mp3, ringtone_wav) = true".
The following are the test operators that the query language can recognize:
= != < > >= <=
Comparing strings follow Python's rules.
Test values can be integers, strings in quotes and the tokens "true" or "false" for boolean tests.
There are two binary operators defined in the language "and" and "or". They can be used between any where statement tests and follow conventional precedence rules:
ringtone=true or ringtone_mp3=false and preferred_markup="wml_1_1" -- becomes -- (ringtone=true or (ringtone_mp3=false and preferred_markup="wml_1_1"))
select id where ringtone=true
select id where ringtone=false and ringtone_mp3=true
select id where rows > 3
select id where all(ringtone_mp3, ringtone_aac, ringtone_qcelp)=true
select ua where preferred_markup = "wml_1_1"
query := select_statement where_statement
select_statement := 'select' ('device' | 'id' | 'ua')
where_statement := 'where' + where_expression
where_expression := where_test (boolop where_test)*
where_test := (any_statement | all_statement | expr_test)
any_statement := 'any' '(' expr_list ')' operator expr
all_statement := 'all' '(' expr_list ')' operator expr
capability := alphanums ('_' alphanums)*
expr_test := expr operator expr
expr_list := expr (',' expr)*
expr := types attributes_methods_concat | capability attributes_methods_concat
attributes_methods_concat := ('.' method '(' method_args? ')')*
method_args := (method_arg (',' method_arg)*)
method_arg := (types | expr)
method := ('_' alphanums)*
operator := ('='|'!='|'<'|'>'|'>='|'<=')
types := (<quote> string <quote> | integer | boolean)
boolean := ('true' | 'false')
boolop := ('and' | 'or')
Author: Armand Lynch <lyncha@users.sourceforge.net>
Copyright: Copyright 2006-2009, Armand Lynch
License: LGPL
|
|||
QueryLanguageError Base exception class for pywurfl.ql |
|||
_Type | |||
TypeNone | |||
TypeNum | |||
TypeStr | |||
TypeBool | |||
TypeList |
|
|||
|
|||
|
|||
|
|||
pyparsing.ParserElement |
|
||
dict |
|
||
function |
|
||
function |
|
||
function |
|
||
function |
|
||
function |
|
||
function |
|
|
|||
__doc__ =
|
|||
__contributors__ =
|
|||
__url__ =
|
|||
ops =
|
|
Defines the pywurfl query language.
|
Returns an exp test function.
|
Combines a list of functions with binary operators.
|
Reduces a sequence of function objects to one function object by applying a binary function recursively to the sequence: In: func = and seq = [func1, func2, func3, func4] Out: and(func1, and(func2, and(func3, func4)))
|
Produces a function that represents the "any" or "all" expression passed in by exp: In: any(ringtone_mp3, ringtone_awb) = true Out: ((ringtone_mp3 = true) or (ringtone_awb = true))
|
Produces a function that encapsulates all the tests from a where statement and takes a Device class or object as a parameter: In (a result object from the following query): select id where ringtone=true and any(ringtone_mp3, ringtone_awb)=true Out: def func(devobj): if (devobj.ringtone == True and (devobj.ringtone_mp3 == True or devobj.ringtone_awb == True)): return True else: return False return func
|
Return a function that can run queries against the WURFL.
|
|
__doc__
|
__contributors__
|
ops
|
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Apr 18 18:56:10 2009 | http://epydoc.sourceforge.net |