Rules¶
-
class
FluidRule(**kwargs)¶ Bases:
dragonfluid._rules.RegisteredRule,dragonfluid._rules.ContinuingRuleA FluidRule is both a
RegisteredRuleand aContinuingRule, 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 theGlobalRegistry, to enabled all features.-
__init__(**kwargs)¶ Parameters: **kwargs – passed to ContinuingRuleandRegisteredRule
-
-
class
QuickFluidRules(grammar)¶ Used like a MappingRule but results in
FluidRule‘s rather than simple CompoundRule‘s.The
mappingattribute 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 toQuickFluidRule.-
__init__(grammar)¶ Not usually called directly, but rather via
ActiveGrammarRule.Parameters: grammar – The Grammar to add rules to, generally a RegistryGrammarsuch as theGlobalRegistry.
-
-
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 theGlobalRegistry, for the registration to actually be performed. Otherwise, it acts like a normal CompoundRule.-
__init__(intros=None, intros_spec=None, **kwargs)¶ For information regarding
introsandintros_spec, refer to the intros documentation.Parameters: - 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
- 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
-
-
class
ContinuingRule(**kwargs)¶ A rule that automatically looks for embedded commands and chains to them. It must be added to a
RegistryGrammar, such as theGlobalRegistryto enable all features.-
__init__(**kwargs)¶ Parameters: **kwargs – passed safely to CompoundRule
-
-
class
QuickFluidRule(spec, action, args={}, **kwargs)¶ Bases:
dragonfluid._rules.FluidRuleA shortcut to assign an action to a spec.
Example:
rule = QuickFluidRule("press home key", Key("home"))
-
__init__(spec, action, args={}, **kwargs)¶ Parameters: - 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
actionis executed, it will then have these final values available to it. - **kwargs – Passed to
FluidRule, except"name"and"spec"ignored.
-