Exemple #1
0
def fetch_todo():
    
    def todo_plugin(name):
        todo=[]
        if plugins.is_installed(name):
            for dep in plugins.headers[name].DEPENDENCIES:
                if extensions.is_installed(dep):
                    todo.append(dep)
                else:
                    return []
            return (todo,name)
        return []
    
    extensions.load()
    plugins.load()
    ext_req=[]
    plugs=[]
    for name in plugins.headers.keys():
        for i in todo_plugin(name):
            ext_req.append(i[0])
            plugs.append(i[1])
        
    todo=[(extensions.load_extension, ext[0]) for ext in ext_req]
            
    for plug in plugs:
        todo.append((plugins.load_plugin, plug))
        
    return todo
Exemple #2
0
def fetch_todo():
    def todo_plugin(name):
        todo = []
        if plugins.is_installed(name):
            for dep in plugins.headers[name].DEPENDENCIES:
                if extensions.is_installed(dep):
                    todo.append(dep)
                else:
                    return []
            return (todo, name)
        return []

    extensions.load()
    plugins.load()
    ext_req = []
    plugs = []
    for name in plugins.headers.keys():
        for i in todo_plugin(name):
            ext_req.append(i[0])
            plugs.append(i[1])

    todo = [(extensions.load_extension, ext[0]) for ext in ext_req]

    for plug in plugs:
        todo.append((plugins.load_plugin, plug))

    return todo
Exemple #3
0
def topicmatch(kw):
    """Return help topics matching kw.

    Returns {'section': [(name, summary), ...], ...} where section is
    one of topics, commands, extensions, or extensioncommands.
    """
    kw = encoding.lower(kw)

    def lowercontains(container):
        return kw in encoding.lower(container)  # translated in helptable

    results = {
        'topics': [],
        'commands': [],
        'extensions': [],
        'extensioncommands': [],
    }
    for names, header, doc in helptable:
        # Old extensions may use a str as doc.
        if (sum(map(lowercontains, names)) or lowercontains(header)
                or (callable(doc) and lowercontains(doc()))):
            results['topics'].append((names[0], header))
    import commands  # avoid cycle
    for cmd, entry in commands.table.iteritems():
        if len(entry) == 3:
            summary = entry[2]
        else:
            summary = ''
        # translate docs *before* searching there
        docs = _(getattr(entry[0], '__doc__', None)) or ''
        if kw in cmd or lowercontains(summary) or lowercontains(docs):
            doclines = docs.splitlines()
            if doclines:
                summary = doclines[0]
            cmdname = cmd.split('|')[0].lstrip('^')
            results['commands'].append((cmdname, summary))
    for name, docs in itertools.chain(
            extensions.enabled(False).iteritems(),
            extensions.disabled().iteritems()):
        # extensions.load ignores the UI argument
        mod = extensions.load(None, name, '')
        name = name.split('.')[-1]
        if lowercontains(name) or lowercontains(docs):
            # extension docs are already translated
            results['extensions'].append((name, docs.splitlines()[0]))
        for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems():
            if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])):
                cmdname = cmd.split('|')[0].lstrip('^')
                if entry[0].__doc__:
                    cmddoc = gettext(entry[0].__doc__).splitlines()[0]
                else:
                    cmddoc = _('(no help text available)')
                results['extensioncommands'].append((cmdname, cmddoc))
    return results
Exemple #4
0
def start():
    import namb.gui as gui
    global m
    m=gui.MainWindow()
    import extensions
    extensions.load()
    extensions.load_extension("vlc")
    import plugins
    plugins.load()
    plugins.install_plugin("radionpo")
    plugins.load_plugin("radionpo")
    #plugins.load_plugin("jazzradio_com")
    global g
    g=plugins.get_plugin("radionpo")
    g.init()
    g.display(m.p.frame)
    import namb.userinput
    namb.userinput.set_receiver(g.menu)
    g.menu.focus_receive()
    m.p.frame.after(1, lambda: m.bar.menu_vanish())
    ui_loop()
Exemple #5
0
def topicmatch(kw):
    """Return help topics matching kw.

    Returns {'section': [(name, summary), ...], ...} where section is
    one of topics, commands, extensions, or extensioncommands.
    """
    kw = encoding.lower(kw)
    def lowercontains(container):
        return kw in encoding.lower(container)  # translated in helptable
    results = {'topics': [],
               'commands': [],
               'extensions': [],
               'extensioncommands': [],
               }
    for names, header, doc in helptable:
        if (sum(map(lowercontains, names))
            or lowercontains(header)
            or lowercontains(doc())):
            results['topics'].append((names[0], header))
    import commands # avoid cycle
    for cmd, entry in commands.table.iteritems():
        if cmd.startswith('debug'):
            continue
        if len(entry) == 3:
            summary = entry[2]
        else:
            summary = ''
        # translate docs *before* searching there
        docs = _(getattr(entry[0], '__doc__', None)) or ''
        if kw in cmd or lowercontains(summary) or lowercontains(docs):
            doclines = docs.splitlines()
            if doclines:
                summary = doclines[0]
            cmdname = cmd.split('|')[0].lstrip('^')
            results['commands'].append((cmdname, summary))
    for name, docs in itertools.chain(
        extensions.enabled(False).iteritems(),
        extensions.disabled().iteritems()):
        # extensions.load ignores the UI argument
        mod = extensions.load(None, name, '')
        name = name.split('.')[-1]
        if lowercontains(name) or lowercontains(docs):
            # extension docs are already translated
            results['extensions'].append((name, docs.splitlines()[0]))
        for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems():
            if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])):
                cmdname = cmd.split('|')[0].lstrip('^')
                if entry[0].__doc__:
                    cmddoc = gettext(entry[0].__doc__).splitlines()[0]
                else:
                    cmddoc = _('(no help text available)')
                results['extensioncommands'].append((cmdname, cmddoc))
    return results