class FluidRule(**kwargs)

Bases: dragonfluid._rules.RegisteredRule, dragonfluid._rules.ContinuingRule

A FluidRule is both a RegisteredRule and a ContinuingRule, meaning it can be chained to from other commands, and then chain off to further commands. This is the most common case, for general use unless you have specific needs. These always attempt to chain automatically.

It must be added to a RegistryGrammar, such as the GlobalRegistry, to enabled all features.

Parameters:**kwargs – passed to ContinuingRule and RegisteredRule
class QuickFluidRules(grammar)

Used like a MappingRule but results in FluidRule‘s rather than simple CompoundRule‘s.

The mapping attribute is extended. In addition to the normal key/value pairs of spec/action, a value may also be a list or tuple whose first element is the usual action, and whose second element is a dict of parameters to be passed as **kwargs to QuickFluidRule.


Not usually called directly, but rather via ActiveGrammarRule.

Parameters:grammar – The Grammar to add rules to, generally a RegistryGrammar such as the GlobalRegistry.
class RegisteredRule(intros=None, intros_spec=None, **kwargs)

A rule that can undergo registration to allow its command to be noticed in the middle of an utterance, allowing other commands to pass off to this rule. It must be added to a RegistryGrammar, such as the GlobalRegistry, for the registration to actually be performed. Otherwise, it acts like a normal CompoundRule.

__init__(intros=None, intros_spec=None, **kwargs)

For information regarding intros and intros_spec, refer to the intros documentation.

  • intros (string, string list, or None) – If None, the command intros will be automatically determined from the spec, otherwise any string provided, by itself or in a list, will be registered as an intro of the command. If supplied, overrides any provided intros_spec.
  • intros_spec (string) – If supplied, will be parsed to obtained the intros for the command, similar in manner to how spec is parsed.
  • **kwargs – passed safely to CompoundRule
class ContinuingRule(**kwargs)

A rule that automatically looks for embedded commands and chains to them. It must be added to a RegistryGrammar, such as the GlobalRegistry to enable all features.

Parameters:**kwargs – passed safely to CompoundRule
class QuickFluidRule(spec, action, args={}, **kwargs)

Bases: dragonfluid._rules.FluidRule

A shortcut to assign an action to a spec.


rule = QuickFluidRule("press home key", Key("home"))
__init__(spec, action, args={}, **kwargs)
  • spec (string) – The spec for this command, from which intros will be determined.
  • action (a dragonfly action) – The action to be executed when this command is said.
  • args (dict) – Provides a way to add to or modify the extras dictionary. The args dictionary has keys of name strings, items of function callbacks. The callbacks are supplied a single parameter of a dictionary of extras, and their return value is assigned to the extra named by the key. When the action is executed, it will then have these final values available to it.
  • **kwargs – Passed to FluidRule, except "name" and "spec" ignored.