ATLAS Offline Software
Loading...
Searching...
No Matches
python.selection Namespace Reference

Functions

 convertNumber (t)
 make_parser (payload_specification)
 make_browse_objects_selection (folder, selection)

Variables

 sign = oneOf('+ -')
 integer = Word(nums)
 number
tuple boolValue
 stringValue = QuotedString("'") | QuotedString('"')
tuple value = boolValue | number | stringValue
 variable = Word(alphanums, min=1)

Function Documentation

◆ convertNumber()

python.selection.convertNumber ( t)

Definition at line 10 of file selection.py.

10def convertNumber(t):
11 if t.is_float:
12 return float(t[0])
13 else:
14 return int(t[0])
15
16# Number defintion

◆ make_browse_objects_selection()

python.selection.make_browse_objects_selection ( folder,
selection )

Definition at line 82 of file selection.py.

82def make_browse_objects_selection(folder, selection):
83 parser = make_parser(folder.folderSpecification().payloadSpecification())
84 return parser(selection)

◆ make_parser()

python.selection.make_parser ( payload_specification)
The parser has to be payload_specification specific because it needs to know
the types of the records to build a FieldSelection.

Definition at line 35 of file selection.py.

35def make_parser(payload_specification):
36 """
37 The parser has to be payload_specification specific because it needs to know
38 the types of the records to build a FieldSelection.
39 """
40
41 def make_selection(string, location, tokens):
42 variable, comparator, value = tokens
43 if payload_specification and variable not in payload_specification:
44 raise RuntimeError("%s is not a value in the folder payload "
45 "specification")
46 elif not payload_specification:
47 return (variable, comparator, value)
48 typeid = payload_specification[variable].storageType().id()
49 return make_fieldselection(variable, typeid, comparator, value)
50
51 from PyCool import cool
52 EQ = Literal("==").setParseAction(lambda t: cool.FieldSelection.EQ)
53 NE = Literal("!=").setParseAction(lambda t: cool.FieldSelection.NE)
54 GE = Literal(">=").setParseAction(lambda t: cool.FieldSelection.GE)
55 LE = Literal("<=").setParseAction(lambda t: cool.FieldSelection.LE)
56 GT = Literal(">") .setParseAction(lambda t: cool.FieldSelection.GT)
57 LT = Literal("<") .setParseAction(lambda t: cool.FieldSelection.LT)
58 comparator = EQ | NE | GE | LE | GT | LT
59 operand = (variable + comparator + value).setParseAction(make_selection)
60
61 orop = Literal("or").suppress()
62 andop = Literal("and").suppress()
63
64 def logic_builder(connective):
65 def thunk(string, location, tokens):
67 for token in tokens[0]:
68 vec.push_back(token)
69
70 return cool.CompositeSelection(connective, vec)
71 return thunk
72
73 expr = StringStart() + operatorPrecedence( operand,
74 [(andop, 2, opAssoc.LEFT, logic_builder(cool.CompositeSelection.AND)),
75 (orop, 2, opAssoc.LEFT, logic_builder(cool.CompositeSelection.OR)),]
76 ) + StringEnd()
77
78 def go(selection):
79 return expr.parseString(selection)[0]
80 return go
81
vector< const cool::IRecordSelection * > make_selection_vector()
cool::FieldSelection * make_fieldselection(const std::string &name, const cool::StorageType::TypeId typeId, cool::FieldSelection::Relation relation, PyObject *refValue)

Variable Documentation

◆ boolValue

tuple python.selection.boolValue
Initial value:
1= (Literal("True") .setParseAction(lambda t: True) |
2 Literal("False").setParseAction(lambda t: False))

Definition at line 28 of file selection.py.

◆ integer

python.selection.integer = Word(nums)

Definition at line 18 of file selection.py.

◆ number

python.selection.number
Initial value:
1= Combine(
2 Optional(sign)
3 + ( ( integer + Optional('.')('is_float') + Optional(integer))
4 | ( Literal('.')('is_float') + Optional(integer))
5 )
6 + Optional( CaselessLiteral('E') + Optional(sign) + integer)('is_float')
7 ).setParseAction(convertNumber)

Definition at line 20 of file selection.py.

◆ sign

python.selection.sign = oneOf('+ -')

Definition at line 17 of file selection.py.

◆ stringValue

python.selection.stringValue = QuotedString("'") | QuotedString('"')

Definition at line 30 of file selection.py.

◆ value

tuple python.selection.value = boolValue | number | stringValue

Definition at line 31 of file selection.py.

◆ variable

python.selection.variable = Word(alphanums, min=1)

Definition at line 33 of file selection.py.