Пример #1
0
def ChkMod(nombre):

    import pydoc
    import re

    pat = re.compile(nombre, re.IGNORECASE)
    resultados = []

    print("\n\n    ",
          end=""), Mark("&"), print(" Módulo: " + color("BB"),
                                    end=""), print(nombre + color("AZC"), "\n")

    def callback(p, n, d):
        if n.endswith(".__init__"):
            n = n[-9:]
        if pat.search(n):
            if n == nombre:
                print("      ", end=""), Mark(">+",
                                              "VC"), color("VC"), print("", n)
            else:
                print("\t    ", end=""), Mark("+",
                                              "VC"), color("VC"), print("", n)
            resultados.append((n, p))

    pydoc.ModuleScanner().run(callback)

    return resultados
Пример #2
0
def list_modules():
    import pydoc

    modules = []

    def module_callback(path, name, description):
        modules.append(name)

    module_scanner = pydoc.ModuleScanner()
    module_scanner.run(module_callback)
    return modules
Пример #3
0
    def doSearch(self):
        key = self.txtSearch.GetValue()
        self.btnStop.Enable(True)
        self.boxResults.Clear()

        import threading, pydoc
        if self.scanner:
            self.scanner.quit = 1
        self.scanner = pydoc.ModuleScanner()
        threading.Thread(target=self.scanner.run,
                         args=(self.OnUpdateResults, key,
                               self.OnFinishedResults)).start()
Пример #4
0
def collectProject(path, dicts):
    global data, _cache
    data = dicts
    for mod, clss in data.items():
        for cls in clss:
            _cache.append(mod + " " + cls)

    os.chdir(path)
    sys.path.append(path)
    pydoc.ModuleScanner().run(callback,
                              key=".",
                              completer=lambda tp=path: completeProject(tp))
    return data
Пример #5
0
    def get_search_results(self, req, query, filters):
        results = []
        if 'pydoc' in filters:
            if not isinstance(query, list):
                query = query.split()
            query = [q.lower() for q in query]
            matched = PyDoc(self.env).filter_match

            def callback(path, modname, desc):
                for q in query:
                    if (path and not matched(path)) and (modname and
                                                         not matched(modname)):
                        return
                    if q in modname.lower() or q in desc.lower():
                        results.append((self.env.href.pydoc(modname), modname,
                                        int(time.time()), 'pydoc', desc or ''))
                        return

            pydoc.ModuleScanner().run(callback)
        return results
Пример #6
0
def callback(path, modname, desc, modules=modules):
    #print("path=%s" % path)
    if re.match("ns\\.", modname):
        if modname not in modules:
            modules.append(modname)
        #print("modname=%s" % modname)
    #print("desc=%s" % desc)
    #print("modules=%s" % modules)


#    if modname and modname[-9:] == ".__init__":
#        modname = modname[:-9]
#    if modname.find(".") < 0 and modname not in modules:
#        modules.append(modname)


def onerror(modname):
    callback(None, modname, None)


pydoc.ModuleScanner().run(callback, onerror=onerror)
#print (modules)

#f = open("bound_attributes.txt", "w")
for m in modules:
    x = importlib.import_module(m)
    attributes = dir(x)
    for a in attributes:
        print(x.__name__ + "." + a)
Пример #7
0
def collectOther(path):
    sys.stderr = NullDevice()
    pydoc.ModuleScanner().run(callback, key=".", completer=complete)
    with open(os.path.join(path, "classes"), "wb") as fil:
        pickle.dump(data, fil)