Exemplo n.º 1
0
    def find(self, names):
        """
          在 list win 中显示由 names 指定的条目
          使用 names 指定 item 而不是通过, 在全局nodes 里查找node 的原因:
            1. frainui 对于子节点的生成是在用户打开节点里的时候才获取地.
                如果进行全局性地查找是找不到的
            2.
        """

        if not names: return
        if not self.root: return

        node = self.root
        for name in names:
            subnode = node.get(name)
            if not subnode:
                node.node_close()
                node.need_fresh = True
                node.node_open()
                subnode = node.get(name)
                if not subnode:
                    break
            else:
                node.node_open()
            node = subnode
        else:
            if subnode:

                self.win.cursor = (subnode.getlinenu(), 0)
                #vim.command('normal zz')

                self.update_status()
                return

        self.win.cursor = (1, 0)
Exemplo n.º 2
0
def collect_fields(node, fragments):
    """Recursively collects fields from the AST
    Args:
        node (dict): A node in the AST
        fragments (dict): Fragment definitions
    Returns:
        A dict mapping each field found, along with their sub fields.
        {'name': {},
         'sentimentsPerLanguage': {'id': {},
                                   'name': {},
                                   'totalSentiments': {}},
         'slug': {}}
    """

    field = {}

    if node.get('selection_set'):
        for leaf in node['selection_set']['selections']:
            if leaf['kind'] == 'Field':
                field.update({
                    leaf['name']['value']: collect_fields(leaf, fragments)
                })
            elif leaf['kind'] == 'FragmentSpread':
                field.update(collect_fields(fragments[leaf['name']['value']],
                                            fragments))

    return field
Exemplo n.º 3
0
    def find(self, names):
        """
          在 list win 中显示由 names 指定的条目
          使用 names 指定 item 而不是通过, 在全局nodes 里查找node 的原因:
            1. frainui 对于子节点的生成是在用户打开节点里的时候才获取地.
                如果进行全局性地查找是找不到的
            2.
        """

        if not names: return
        if not self.root: return

        node = self.root
        for name in names:
            subnode = node.get(name)
            if not subnode:
                node.node_close()
                node.need_fresh = True
                node.node_open()
                subnode = node.get(name)
                if not subnode:
                    break
            else:
                node.node_open()
            node = subnode
        else:
            if subnode:
                #self.BFw.cursor = (subnode.getlinenu(), subnode.level * 2 - 1)
                self.BFw.cursor = (subnode.getlinenu(), 0)
                self.update_status()

                w = None
                if self.BFw != vim.current.window:
                    w = vim.current.window
                    vim.current.window = self.BFw

                #在 list 窗口中显示当前行
                vim.command('call winline()')
                #vim.command('normal zs')
                if w:
                    vim.current.window = w
                return

        self.BFw.cursor = (1, 0)
Exemplo n.º 4
0
    try:
        new_node = False;
        while True:
            user_input = raw_input("Is this a new node[y/N]?")
            if user_input is "":
                user_input = "n"
            user_input = user_input.lower()
            if user_input == "y" or user_input == "n":
                if user_input == "y":
                    new_node = True
                else:
                    new_node = False
                break

        log.current_state = "Ready to do the handshake"
        response = httpclient.post(api.__handshake__, node.get(new_node, auth.__user_id__), auth.checkResponse)
        print response.status, response.reason
        if response.status == 200:
            #print response.body
            body = json.loads(response.body)
            node.update(body)

            log.current_state = "Handshake succeeded"
            print "handshake succeeded"
    except:
        error_msg = "handshake fail"
        e = sys.exc_info()[0]
        print error_msg
        error_msg = "\n" + error_msg + "\n" + str(e)
        log.log_error(error_msg)