Exemplo n.º 1
0
def listObjByName(gui):
    """
    Displays all catalog information about an object given its name.
    
    :param tkwidget gui: GUI object from which the request came
    """
    prt = gui.getPrtInstance()

    if (not ASTCatalog.isCatalogLoaded()):
        ASTMsg.errMsg("No catalog is currently loaded.", "No Catalog Loaded")
        return

    if (ASTQuery.showQueryForm(["Enter the Object's Name"]) !=
            ASTQuery.QUERY_OK):
        return

    searchStr = ASTQuery.getData(1)
    if ((searchStr == None) or (len(searchStr) <= 0)):
        return

    prt.clearTextArea()
    idx = ASTCatalog.findObjByName(searchStr.strip())
    if (idx < 0):
        prt.println("No object named '" + searchStr +
                    "' was found in the catalog")
    else:
        ASTCatalog.displayFullObjInfo(idx)

    prt.resetCursor()
Exemplo n.º 2
0
def listObjByComments(gui):
    """
    Displays detailed information about catalog objects that
    contain a target substring in their "comments" field.

    :param tkwidget gui: GUI object from which the request came
    """
    prt = gui.getPrtInstance()

    if (not ASTCatalog.isCatalogLoaded()):
        ASTMsg.errMsg("No catalog is currently loaded.", "No Catalog Loaded")
        return

    if (ASTQuery.showQueryForm([
            "Enter Substring to Search for in the Object's 'Comments' Field"
    ]) != ASTQuery.QUERY_OK):
        return

    searchStr = ASTQuery.getData(1)
    if ((searchStr == None) or (len(searchStr) <= 0)):
        return

    prt.clearTextArea()

    iResult = ASTCatalog.findObjsByComments(searchStr.strip())

    n = len(iResult)

    if (n <= 0):
        prt.println("No Objects in the current Catalog have the substring '" +
                    searchStr + "' in their 'Comments' field")
    else:
        if (n == 1):
            prt.println("One Object has the substring '" + searchStr +
                        "' in it's 'Comments' field")
        else:
            prt.println(
                str(n) + " Objects have the substring '" + searchStr +
                "' in their 'Comments' field")

        for i in range(0, n):
            prt.println()
            prt.setFixedWidthFont()
            prt.println("*" * 80)
            prt.setProportionalFont()
            prt.println("Object # " + str(i + 1))
            ASTCatalog.displayFullObjInfo(iResult[i])

    prt.resetCursor()