Next: , Previous: , Up: Python   [Contents][Index]


5.6.2 Dico Python Primitives

Python primitive: register_strat name descr [proc]

Registers new match strategy. The arguments are:

name

Strategy name for use in the MATCH command.

descr

The dscription, which will appear in the output of SHOW STRAT command.

proc

Optional selector procedure.

If the proc argument is present, it must be the name of a Python function declared as:

def select(opcode key headword):

Its arguments are:

opcode

Integer operation code.

key

An DicoSelectionKey object identifying the search term (see The DicoSelectionKey class).

headword

The headword being examined.

At the beginning of the search, the function is called with the ‘DICO_SELECT_BEGIN’ as its opcode argument. It must perform the necessary initialization and return.

At the end of the search loop, the function is called with opcodeDICO_SELECT_END’. It must perform the necessary deinitialization procedures and exit.

In both cases, the key and headword arguments are not defined.

Within the search loop, the function will be called for each headword from the database. The opcode parameter will be ‘DICO_SELECT_RUN’. In this case the function must return ‘True’ if the headword matches the key and ‘False’ otherwise.

Python primitive: register_markup name

Registers a markup name.

Python primitive: current_markup

Returns the name of the current markup.


Next: Python Example, Previous: Python Dictionary Class, Up: Python   [Contents][Index]