コード例 #1
0
    def main(self):
        F = npyscreen.Form(name="Testing Tree class", )
        #wgtree = F.add(npyscreen.MLTree)
        wgtree = F.add(TestTree)

        treedata = npyscreen.NPSTreeData(content='Root',
                                         selectable=True,
                                         ignoreRoot=False)
        c1 = treedata.newChild(content='Child 1',
                               selectable=True,
                               selected=True)
        c2 = treedata.newChild(content='Child 2', selectable=True)
        g1 = c1.newChild(content='Grand-child 1', selectable=True)
        g2 = c1.newChild(content='Grand-child 2', selectable=True)
        g3 = c1.newChild(content='Grand-child 3')
        gg1 = g1.newChild(content='Great Grand-child 1', selectable=True)
        gg2 = g1.newChild(content='Great Grand-child 2', selectable=True)
        gg3 = g1.newChild(content='Great Grand-child 3')
        wgtree.values = treedata

        F.edit()

        global RETURN
        #RETURN = wgtree.values
        RETURN = wgtree.get_selected_objects()
コード例 #2
0
def pytest_collection_modifyitems(session, config, items):
    if not (config.option.menu and items):
        return

    capman = config.pluginmanager.getplugin("capturemanager")
    if capman:
        capman.suspendcapture(in_=True)

    tests = {}
    for test_item in items:
        t = tests
        path = get_path(test_item)
        for layer in path[:-1]:
            if layer not in t:
                t[layer] = {}
            t = t[layer]
        assert not path[
            -1] in t  # This would mean we have to test cases with the same name an path, should not be possible
        t[path[-1]] = test_item

    test_tree = npyscreen.NPSTreeData(content=session.name, ignoreRoot=False)
    add_children(test_tree, tests)
    test_choices = ask_user(choices=test_tree, name="Test Selection")

    test_cases = []
    for i in test_choices:
        test_cases.append(i)
    test_cases = [
        x.test_case for x in test_cases if hasattr(x, "test_case")
        if x.test_case not in test_cases
    ]
    test_cases = [x for x in test_cases if type(x) == pytest.Function]
    items[:] = test_cases  # Set pytest item list to selected test cases
コード例 #3
0
 def fetch_topics(self):
     tp = self.parentApp.tp_client
     lst = tp.topics()
     treedata = npyscreen.NPSTreeData(content=tp.namespace,
                                      selectable=True,
                                      ignoreRoot=False)
     tpc = subc = 0
     for topic_name, sb_lst in lst:
         tp_selected = self.topic_name == topic_name
         t = treedata.newChild(content=topic_name,
                               selectable=False,
                               selected=tp_selected)
         tpc = tpc + 1
         for sb in sb_lst:
             sb_selected = self.sub_name == sb.name
             title = "%s (%d)" % (sb.name, sb.message_count)
             sub_node = t.newChild(content=title,
                                   selectable=True,
                                   selected=sb_selected)
             sub_node.newChild(content='queue', selectable=True)
             sub_node.newChild(content='dlq', selectable=True)
             subc = subc + 1
     self.wTopics.values = treedata
     self.wTopics.footer = "Topics (%s), Subs (%d)" % (tpc, subc)
     self.wTopics.display()
コード例 #4
0
    def addRegType(self):
        #regex
        selected = self.tree.get_selected_objects(return_node=False)
        selected = [x for x in selected]
        regVal = self.regex.value
        if regVal is "":
            regVal = "(.*?)"  #match anything

        RDBOBJECT.add_regex_to_servers(regVal, selected)

        #type
        selected_type = self.chosenType.get_selected_objects()
        if not selected_type:  #Do not accept no db
            npyscreen.notify_confirm("No key type selected",
                                     title='Error',
                                     editw=1)
            return
        RDBOBJECT.add_selected_key_type(selected, selected_type)

        treedata = npyscreen.NPSTreeData(content='Redis servers',
                                         selectable=False,
                                         ignoreRoot=False)
        for serv in RDBOBJECT.get_target_redis_servers():
            n = treedata.newChild(content=serv, selectable=True)
            for r in RDBOBJECT.get_regexes_from_server(serv):
                n.newChild(content=r, selectable=False)
            n.newChild(content=RDBOBJECT.get_selected_type()[serv],
                       selectable=False)

        self.tree.values = treedata
        self.regex.value = ''
        self.tree.display()
コード例 #5
0
    def main(self):

        wgtree = self.add(npyscreen.MLTreeMultiSelect)

        treedata = npyscreen.NPSTreeData(content='root',
                                         selectable=True,
                                         ignoreRoot=False)
        treedata.path = ""
        for cat in j.tools.nodemgr.tree.children:
            if cat.name == "":
                continue
            currootTree = treedata.newChild(content='{} ({})'.format(
                cat.name, cat.cat),
                                            selectable=True,
                                            selected=cat.selected)
            currootTree.path = cat.path
            for node in cat.children:
                nodeTree = currootTree.newChild(content='{} ({})'.format(
                    node.name, node.cat),
                                                selectable=True,
                                                selected=node.selected)
                nodeTree.path = node.path

        wgtree.values = treedata
        self.wgtree = wgtree
コード例 #6
0
    def main(self):
        wgtree = self.add(npyscreen.MLTreeMultiSelect)

        treedata = npyscreen.NPSTreeData(content='coderoot',
                                         selectable=True,
                                         ignoreRoot=False)
        treedata.path = ""
        for ttype in j.tools.develop.codedirs.tree.children:
            currootTree = treedata.newChild(content=ttype.name,
                                            selectable=True,
                                            selected=ttype.selected)
            currootTree.path = ttype.path
            for account in ttype.children:
                accTree = currootTree.newChild(content=account.name,
                                               selectable=True,
                                               selected=account.selected)
                accTree.path = account.path
                for repo in account.children:
                    lowestChild = accTree.newChild(content=repo.name,
                                                   selectable=True,
                                                   selected=repo.selected)
                    lowestChild.path = repo.path

        wgtree.values = treedata
        self.wgtree = wgtree
コード例 #7
0
ファイル: stdfmemail.py プロジェクト: wrapperband/leo-editor
 def _parse_email_tree(self, this_email):
     "Create an NPSTree representation of the email."
     self._this_email_tree = npyscreen.NPSTreeData(content=this_email,
                                                   ignoreRoot=False)
     if this_email.is_multipart():
         for part in this_email.get_payload():
             self._tree_add_children(self._this_email_tree, part)
コード例 #8
0
ファイル: sample.py プロジェクト: anton-shanin/tui_sample
    def create(self):
        y, x = self.useable_space()
        myFW = self.add(npyscreen.TitleText)
        gd = self.add(MyGrid,
                      col_titles=['Col1', 'Col2', 'Col3', 'Col4'],
                      max_width=x // 10 * 7,
                      max_height=y)

        # Adding values to the Grid, this code just randomly
        # fills a 2 x 4 grid with random PASS/FAIL strings.
        gd.values = []
        for x in range(10):
            row = []
            for y in range(4):
                if bool(random.getrandbits(1)):
                    row.append("Data1")
                else:
                    row.append("Data2")
            gd.values.append(row)
        # F.edit()

        # self.myName = self.add(nameField, name='Name')
        # self.myDepartment = self.add(departmentSelect, scroll_exit=True, max_height=3, name='Department',
        #                              values=['Department 1', 'Department 2', 'Department 3'])
        # self.myDate = self.add(npyscreen.TitleDateCombo, name='Date Employed')

        self.myTree = self.add(npyscreen.MLTreeMultiSelect,
                               name='Fields',
                               relx=x // 10 * 7 + 1,
                               rely=y,
                               max_width=x // 10 * 3,
                               max_height=y)

        treecontent = npyscreen.NPSTreeData(content='Root',
                                            selectable=True,
                                            ignoreRoot=False)
        c1 = treecontent.newChild(content='Child 1',
                                  selectable=True,
                                  selected=True)
        c2 = treecontent.newChild(content='Child 2', selectable=True)
        g1 = c1.newChild(content='Grand-child 1', selectable=True)
        g2 = c1.newChild(content='Grand-child 2', selectable=True)
        g3 = c1.newChild(content='Grand-child 3')
        gg1 = g1.newChild(content='Great Grand-child 1', selectable=True)
        gg2 = g1.newChild(content='Great Grand-child 2', selectable=True)
        gg3 = g1.newChild(content='Great Grand-child 3')
        self.myTree.values = treecontent
コード例 #9
0
    def create(self):
        self.chosenType = self.add(
            npyscreen.TitleMultiSelect,
            max_height=10,
            max_width=40,
            name="Select type from the RDB file to be imported:",
            value=[x for x in range(len(RDBOBJECT.list_keyType()))],
            values=RDBOBJECT.list_keyType())
        self.vspace()

        self.regex = self.add(npyscreen.TitleText, name='Regex:', value='')
        self.vspace(2)
        self.add(npyscreen.TitleFixedText,
                 name='Select redis database for which this regex applies:',
                 value='',
                 editable=False)
        self.tree = self.add(npyscreen.MLTreeMultiSelect,
                             max_height=30,
                             max_width=80)
        treedata = npyscreen.NPSTreeData(content='Redis servers',
                                         selectable=False,
                                         ignoreRoot=False)
        for serv in RDBOBJECT.get_target_redis_servers():
            n = treedata.newChild(content=serv, selectable=True)
            for r in RDBOBJECT.get_regexes_from_server(serv):
                n.newChild(content=r, selectable=False)
            n.newChild(content=RDBOBJECT.get_selected_type()[serv],
                       selectable=False)

        self.tree.values = treedata

        self.add_button = self.add(npyscreen.ButtonPress,
                                   name='Add',
                                   relx=self.tree.width + 10,
                                   rely=19)
        self.add_button.whenPressed = self.addRegType
コード例 #10
0
import npyscreen

tree_data = npyscreen.NPSTreeData()
tree_data.newChild(content={'a': 1})
q = tree_data.newChild(content={'b': 2})
q.newChild(content={'c': 4})


class MyTreeLineAnnotated(npyscreen.TreeLineAnnotated):
    def getAnnotationAndColor(self):
        # AHH, self.value is an empty str, this fails.
        #if self.value:
        content = str(self.value)
        return (content, self._annotatecolor)

    def display_value(self, vl):
        return str(vl)


class MyTree(npyscreen.MultiLineTreeNew):
    _contained_widgets = MyTreeLineAnnotated

    def display_value(self, vl):
        return vl


class MyForm(npyscreen.Form):
    def create(self):
        self.series_view = self.add(MyTree, values=tree_data)