示例#1
0
                       Section, Item)

#---------------------------------------------------------------------------
# Set up this module's configuration.

config = Config("config manager")
config.lang = Section("Language section")
config.lang.list_configs = Item("list configs", doc="Command to ...")
config.lang.edit_config = Item("edit <config> (config | configuration)",
                               doc="Command to ...")
config.lang.show_dragonfly_version = Item("show dragonfly version",
                                          doc="Command to ...")
config.lang.update_dragonfly = Item("update dragonfly version",
                                    doc="Command to ...")
config.lang.reload_natlink = Item("reload natlink", doc="Command to ...")
config.load()

#---------------------------------------------------------------------------

config_map = DictList("config_map")

#---------------------------------------------------------------------------


class ConfigManagerGrammar(Grammar):
    def __init__(self):
        Grammar.__init__(self, name="config manager", context=None)

    def _process_begin(self, executable, title, handle):
        configs = Config.get_instances()
示例#2
0
#---------------------------------------------------------------------------
# Set up this module's configuration.

config                   = Config("config manager")
config.lang              = Section("Language section")
config.lang.list_configs = Item("list configs",
                                doc="Command to ...")
config.lang.edit_config  = Item("edit <config> (config | configuration)",
                                doc="Command to ...")
config.lang.show_dragonfly_version = Item("show dragonfly version",
                                doc="Command to ...")
config.lang.update_dragonfly = Item("update dragonfly version",
                                doc="Command to ...")
config.lang.reload_natlink   = Item("reload natlink",
                                doc="Command to ...")
config.load()


#---------------------------------------------------------------------------

config_map = DictList("config_map")


#---------------------------------------------------------------------------

class ConfigManagerGrammar(Grammar):

    def __init__(self):
        Grammar.__init__(self, name="config manager", context=None)

    def _process_begin(self, executable, title, handle):
from dragonfly import Config, Section, Item, AppContext, Grammar, MappingRule, IntegerRef, Dictation, Choice

from lib.dynamic_aenea import (
    DynamicContext,
    Key,
    Text,
)

from proxy_nicknames import AppContext as NixAppContext

hipchat_config = Config("HipChat")
hipchat_config.usernames = Section("Username Mappings")
hipchat_config.usernames.map = Item({"All": "all", "Here": "here"})

hipchat_config.load()


class NavigationRule(MappingRule):
    mapping = {
        "move up [<n>]":
        Key("cs-tab:%(n)d"),
        "move down [<n>]":
        Key("c-tab:%(n)d"),
        "close tab":
        Key("c-w"),
        "(join room | private message) <room>":
        Key("c-j/25") + Text("%(room)s") + Key("enter"),
        "search [room] history":
        Key("c-f"),
    }
    Key,
    Text,
)

from aenea.proxy_contexts import ProxyAppContext as NixAppContext

hipchat_config = Config("HipChat")
hipchat_config.usernames = Section("Username Mappings")
hipchat_config.usernames.map = Item(
    {
        "All": "all",
        "Here": "here"
    }
)

hipchat_config.load()

class NavigationRule(MappingRule):
    mapping = {
        "move up [<n>]":                                    Key("cs-tab:%(n)d"),
        "move down [<n>]":                                  Key("c-tab:%(n)d"),
        "close tab":                                        Key("c-w"),
        "(join room | private message) <room>":             Key("c-j/25") + Text("%(room)s") + Key("enter"),
        "search [room] history":                            Key("c-f"),
    }

    extras = [
        IntegerRef("n", 1, 10),
        Dictation("room"),
    ]
示例#5
0
from dragonfly import Function, MappingRule, Text, Dictation, Config, Section, Item, Key

config = Config("format functions")
config.cmd = Section("Command section")
config.cmd.map = Item(
    {},
    namespace={
        "Key": Key,
        "Text": Text,
    }
)
namespace = config.load()


#---------------------------------------------------------------------------
# Here we prepare the list of formatting functions from the config file.

# Retrieve text-formatting functions from this module's config file. Each of these functions must have a name that starts with "format_".
format_functions = {}
if namespace:
    for name, function in namespace.items():
        if name.startswith("format_") and callable(function):
            spoken_form = function.__doc__.strip()

            # We wrap generation of the Function action in a function so that its *function* variable will be local.  Otherwise it
            #  would change during the next iteration of the namespace loop.
            def wrap_function(function):
                def _function(dictation):
                    formatted_text = function(dictation)
                    Text(formatted_text).execute()
示例#6
0
#grammar = Grammar("Dynamic manager", context=None)
grammar = DynamicManagerGrammar()
grammar.add_rule(series_rule)
grammar.load()


notify()  # Notify that Dragonfly is ready with a sound.


def unload():
    """Unload function which will be called at unload time."""
    # Unload the dynamically loaded modules.
    global moduleMapping
    for module in moduleMapping.values():
        print "---------- " + __file__.split('\\')[-1] + " unload(): " + str(module.__name__)
        module.unload()

    global grammar
    if grammar:
        grammar.unload()
    grammar = None

#---------------------------------------------------------------------------
# Set up this module's configuration. In this module's particular case, this doesn't necessarily make alot of sense, as this file/module is not expected to be edited every day, and it doesn't have/need a config file ie .txt, but having this make it easier to bring this module into notepad via _dragonfly_tools.py/config manager "edit dynamic manager module" command
# may be should combine dynamics/*.py into one _dragonfly_tools.txt config file, so that on editing the config file the the main .py module gets touced (via a method in _dragonfly_tools.py) and cause it to reload (even thought this reload is not reliable and sometimes needs sleep/wakeup or microphoneOff/microphoneOn to properly reload the newly edited moudle and it's config)
# alternatively re-employ the method/function of _dragonfly_tools.py that touches the .py when .txt is edited, to make it re-touch _dynamic_manager.py when any of dynamics/*.py is edited

from dragonfly import Config
dragonfly_config = Config("dynamic manager") # config is already used for lib/config.py's config.json file
dragonfly_config.load()