`res` is a dict with the following structure Dict(NodeName, CommandResult)
554769
def _merge_result(self, command, res, **kwargs):
        
        if command in self.result_callbacks:
            return self.result_callbacks[command](res, **kwargs)

        # Default way to handle result
        return first_key(res)
276164
def _process_json_resp_data(resp, no_custom_fields=False):
    
    bridge_users = []
    while True:
        resp_data = json.loads(resp)
        link_url = None
        if "meta" in resp_data and\
                "next" in resp_data["meta"]:
            link_url = resp_data["meta"]["next"]

        bridge_users = _process_apage(resp_data, bridge_users,
                                      no_custom_fields)
        if link_url is None:
            break
        resp = get_resource(link_url)

    return bridge_users
401452
def post2pydict(post, ignore_list):
    """"""
    root_element = PYUNTL_DISPATCH['metadata']()
    untl_form_dict = {}
    # Turn the posted data into usable data
    # (otherwise the value lists get messed up).
    form_post = dict(post.copy())
    # Loop through all the field lists.
    for key, value_list in form_post.items():
        if key not in ignore_list:
            # Split the key into the element_tag (ex. title)
            # and element attribute (ex. qualifier, content).
            (element_tag, element_attribute) = key.split('-', 1)
            if element_tag not in untl_form_dict:
                untl_form_dict[element_tag] = ()
            # Add the value list to the dictionary.
            untl_form_dict[element_tag] += (element_attribute, value_list),

    for element_tag, attribute_tuple in untl_form_dict.items():
        # Get the count of attributes/content in the element tuple.
        attribute_count = len(attribute_tuple)
        # Get the count of the first attribute's values.
        value_count = len(attribute_tuple[0][1])
        # Check to see that all attribute/content values align numerically.
        for i in range(0, attribute_count):
            if not len(attribute_tuple[i][1]) == value_count:
                raise PyuntlException('Field values did not match up '
                                      'numerically for %s' % (element_tag))
        # Create a value loop to get all values from the tuple.
        for i in range(0, value_count):
            untl_element = None
            content = ''
            qualifier = ''
            child_list = []
            # Loop through the attributes.
            # attribute_tuple[j][0] represents the attribute/content name.
            # attribute_tuple[j][1][i] represents the
            # current attribute/content value.
            for j in range(0, attribute_count):
                if attribute_tuple[j][0] == 'content':
                    content = unicode(attribute_tuple[j][1][i])
                elif attribute_tuple[j][0] == 'qualifier':
                    qualifier = attribute_tuple[j][1][i]
                # Create a child UNTL element from the data.
                else:
                    # If the child has content, append it to the child list.
                    if attribute_tuple[j][1][i] != '':
                        child_tag = attribute_tuple[j][0]
                        # Check if the child is the attribute of the element.
                        if child_tag in PARENT_FORM:
                            qualifier = attribute_tuple[j][1][i]
                        # Else, the child is a normal child of the element.
                        else:
                            child_list.append(
                                PYUNTL_DISPATCH[attribute_tuple[j][0]](
                                    content=attribute_tuple[j][1][i]
                                )
                            )
            # Create the UNTL element.
            if content != '' and qualifier != '':
                untl_element = PYUNTL_DISPATCH[element_tag](content=content,
                                                            qualifier=qualifier)
            elif content != '':
                untl_element = PYUNTL_DISPATCH[element_tag](content=content)
            elif qualifier != '':
                untl_element = PYUNTL_DISPATCH[element_tag](qualifier=qualifier)
            # This element only has children elements.
            elif len(child_list) > 0:
                untl_element = PYUNTL_DISPATCH[element_tag]()
            # If the element has children, add them.
            if len(child_list) > 0 and untl_element is not None:
                for child in child_list:
                    untl_element.add_child(child)
            # Add the UNTL element to the root element.
            if untl_element is not None:
                root_element.add_child(untl_element)
    return root_element.create_element_dict()
1338656
def prefix_dict_keys(d: Dict[str, Any], prefix: str) -> Dict[str, Any]:
    
    result = {}  # type: Dict[str, Any]
    for k, v in d.items():
        result[prefix + k] = v
    return result
1090004
def _from_dict(cls, _dict):
        """"""
        args = {}
        xtra = _dict.copy()
        if 'log_messages' in _dict:
            args['log_messages'] = [
                LogMessage._from_dict(x) for x in (_dict.get('log_messages'))
            ]
            del xtra['log_messages']
        else:
            raise ValueError(
                'Required property \'log_messages\' not present in OutputData JSON'
            )
        if 'text' in _dict:
            args['text'] = _dict.get('text')
            del xtra['text']
        else:
            raise ValueError(
                'Required property \'text\' not present in OutputData JSON')
        if 'generic' in _dict:
            args['generic'] = [
                DialogRuntimeResponseGeneric._from_dict(x)
                for x in (_dict.get('generic'))
            ]
            del xtra['generic']
        if 'nodes_visited' in _dict:
            args['nodes_visited'] = _dict.get('nodes_visited')
            del xtra['nodes_visited']
        if 'nodes_visited_details' in _dict:
            args['nodes_visited_details'] = [
                DialogNodeVisitedDetails._from_dict(x)
                for x in (_dict.get('nodes_visited_details'))
            ]
            del xtra['nodes_visited_details']
        args.update(xtra)
        return cls(**args)
1360430
def _assert_command_dict(self, struct, name, path=None, extra_info=None):
        """"""
        self._assert_dict(struct, name, path, extra_info)
        if len(struct) != 1:
            err = [self._format_error_path(path + [name])]
            err.append('Commands of run, dependencies, and argument sections must be mapping with '
                       'exactly 1 key-value pair, got {0}: {1}'.format(len(struct), struct))
            if extra_info:
                err.append(extra_info)
            raise exceptions.YamlSyntaxError('\n'.join(err))
780369
def build(sub_parser, cmds):
    

    res = {}
    for cmd in cmds:
        res[cmd.name] = cmd(sub_parser)
    # end for cmd in cmds

    return res
564649
function _resp2json(doc){
	console.log("_resp2json: " + doc);

	var kids = []; // ret

	// Extract the intersting graphs.
	var topo_graph_field = 'topology_graph_json';
	var trans_graph_field = 'regulates_transitivity_graph_json';
	var topo_graph = new model.graph();
	topo_graph.load_base_json(JSON.parse(doc[topo_graph_field]));
	var trans_graph = new model.graph();
	trans_graph.load_base_json(JSON.parse(doc[trans_graph_field]));

	//console.log('topo: ' + doc[topo_graph_field]);

	// Collect child ids.
	var child_ids = [];
	us.each(topo_graph.get_child_nodes(doc['id']), function(kid){
	    child_ids.push(kid.id());
	});

	// Using the badger, get the spans for the IDs.
	var ac_badges = new CountBadges(filter_manager);
	var ids_to_badge_text = ac_badges.get_future_badges(child_ids);

	//
	us.each(topo_graph.get_child_nodes(doc['id']), function(kid){

	    // Extract some info.
	    var oid = doc['id'];
	    var sid = kid.id();
	    var preds = topo_graph.get_predicates(sid, oid);
	    var imgsrc = bbop.resourcify(sd.image_base, preds[0], 'gif');

	    var lbl_txt =  kid.label() || sid;
	    
	    // Push template.
	    kids.push({
		'id': sid,
		'text': lbl_txt + ids_to_badge_text[sid],
		'icon': imgsrc,
		'state': {
		    'opened': false,
		    'disabled': false,
		    'selected': false
		},
		'children': true, // unknowable w/o lookahead
		'li_attr': {},
		'a_attr': {}
	    });
	});

	return kids;
    }
1035506
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'folders' in _dict:
            args['folders'] = [
                SourceOptionsFolder._from_dict(x)
                for x in (_dict.get('folders'))
            ]
        if 'objects' in _dict:
            args['objects'] = [
                SourceOptionsObject._from_dict(x)
                for x in (_dict.get('objects'))
            ]
        if 'site_collections' in _dict:
            args['site_collections'] = [
                SourceOptionsSiteColl._from_dict(x)
                for x in (_dict.get('site_collections'))
            ]
        if 'urls' in _dict:
            args['urls'] = [
                SourceOptionsWebCrawl._from_dict(x) for x in (_dict.get('urls'))
            ]
        if 'buckets' in _dict:
            args['buckets'] = [
                SourceOptionsBuckets._from_dict(x)
                for x in (_dict.get('buckets'))
            ]
        if 'crawl_all_buckets' in _dict:
            args['crawl_all_buckets'] = _dict.get('crawl_all_buckets')
        return cls(**args)
735720
def visit_Dict(self, node):
        
        if node.keys:
            items = node.keys + node.values
            return list(set(sum([self.visit(item) for item in items], [])))
        else:
            return [frozenset()]
509100
def from_dict(cls, d):
        
        def _node(obj):
            return Node(
                obj.get('nodeid'),
                Pred.surface_or_abstract(obj.get('predicate')),
                sortinfo=obj.get('sortinfo'),
                lnk=_lnk(obj.get('lnk')),
                surface=obj.get('surface'),
                base=obj.get('base'),
                carg=obj.get('carg')
            )
        def _link(obj):
            return Link(obj.get('from'), obj.get('to'),
                        obj.get('rargname'), obj.get('post'))
        def _lnk(o):
            return None if o is None else Lnk.charspan(o['from'], o['to'])
        return cls(
            nodes=[_node(n) for n in d.get('nodes', [])],
            links=[_link(l) for l in d.get('links', [])],
            lnk=_lnk(d.get('lnk')),
            surface=d.get('surface'),
            identifier=d.get('identifier')
        )
955262
def get_dict_from_response(response):
    """"""
    result = {}
    if getattr(response, '_resp') and response._resp.code > 400:
        return result

    for i in response.data:
        # strip the schema from the key
        k = i['Type'].replace(REMOTE_APP_RESOURCE_SCHEMA, '')
        result.setdefault(k, list())
        result[k].append(i['Value'])
    return result
995898
def to_dict(self, properties=True):
        
        nodes = {}
        for node in self.nodes():
            nd = {
                'label': node.pred.short_form(),
                'edges': self.edges(node.nodeid)
            }
            if node.lnk is not None:
                nd['lnk'] = {'from': node.cfrom, 'to': node.cto}
            if properties:
                if node.cvarsort is not None:
                    nd['type'] = node.cvarsort
                props = node.properties
                if props:
                    nd['properties'] = props
            if node.carg is not None:
                nd['carg'] = node.carg
            nodes[node.nodeid] = nd
        return {'top': self.top, 'nodes': nodes}
376221
def main
      program_desc 'Manipulate and view the ASIObjectDictionary.xml and BOD.json files'

      version AsiBod::VERSION

      subcommand_option_handling :normal
      arguments :strict
      sort_help :manually

      desc 'Path to the ASIObjectDictionary XML file'
      default_value Asi.default_file_path
      flag [:a, :asi_file]

      desc 'Path to the BOD JSON file'
      default_value Bod.default_file_path
      flag [:b, :bod_file]

      desc 'View Address'
      switch :address_view, default_value: true

      desc 'View Name'
      switch :name_view, default_value: true

      desc 'View Description'
      switch :description_view, default_value: true

      desc 'View Scale'
      switch [:s, :scale_view]

      desc 'View Units'
      switch [:u, :units_view]

      desc 'View the data'
      command :view do |view|
        view.desc 'Pretty Print output of the simplified ASI ObjectDictionary as a hash'
        view.command :asi do |view_asi| 
          view.desc 'Output as Json instead of CSV'
          view.switch [:j, :json]

          view_asi.action do |global_options, options, args|
            if options[GPARENT][:json]
              puts JSON.pretty_generate asi.hash_data
            else
              Dict.specific_keys_per_node(
                asi.hash_data,
                which_keys(global_options)) do |address, node|
                puts node
              end
            end
          end
        end

        view.desc 'Pretty Print output of the simplified BOD as a hash'
        view.command :bod do |view_bod|
          view_bod.action do |global_options,options,args|
            if options[GPARENT][:json]
              puts JSON.pretty_generate bod.hash_data
            else
              Dict.specific_keys_per_node(
                bod.hash_data,
                which_keys(global_options)).each_pair do |address, node|
                puts node
              end
            end
          end
        end
        view.default_command :bod
      end

      desc 'Find a node in one or both of the dictionaries'
      command :find do |find|
        find.desc 'Search the asi dictionary'
        find.switch [:a, :asi]

        find.desc 'Search the bod dictionary'
        find.switch [:b, :bod]

        find.desc 'Find by register address'
        find.long_desc 'Find by register address. ' +
                       'Must select at least one of ' +
                       'asi or bod and specify search_term'
        find.arg 'address'
        find.command :by_address do |find_by_address| 
          find_by_address.action do |global_options, options, args|
            address = args.first
            # puts "find_by_address global_options #{global_options.inspect} options: #{options.inspect} args: #{args.inspect}"
            puts "asi: => " +
                 "#{Dict.node_line(asi.hash_data[address.to_i],
                    which_keys(global_options))}" if options[GPARENT][:asi]
            puts "bod: => " +
                 "#{Dict.node_line(bod.hash_data[address.to_i],
                    which_keys(global_options))}" if options[GPARENT][:bod]
          end
        end

        find.desc 'Find by the substring of a key'
        find.long_desc 'Find by the substring of ' +
                       'a Must select at least one of ' +
                       'asi or bod and specify search_term'
        find.arg 'node_key'
        find.arg 'substring'
        find.command :by_key_substring do |find_by_key_substring| 
          find_by_key_substring.action do |global_options, options, args|
            key = args[0].to_sym
            substring = args[1]
            if options[GPARENT][:asi]
              puts "asi: key: #{key} substring: #{substring} => "
              Dict.find_by_key_substring(asi.hash_data, key, substring,
                                              which_keys(global_options)
                                        ).each_pair do |address, node|
                puts node
              end
            end
            if options[GPARENT][:bod]
              puts "bod: key: #{key} substring: #{substring} => "
              Dict.find_by_key_substring(bod.hash_data, key, substring,
                                              which_keys(global_options)
                                           ).each_pair do |address, node|
                puts node
              end
            end
          end
        end
      end

      desc 'Merge the Description from asi to bod'
      long_desc 'Merge the Description from asi to bod ' +
                'Do not merge if Description has "Reserved" in it ' +
                'Or if the Bod doesnt have the key'
      command :merge do |merge|
        merge.desc 'Output Json'
        merge.switch [:j, :json]
        merge.action do |global_options,options,args|
          raw_result = Dict.merge(asi.hash_data, bod.hash_data)
          result = if options[:json]
                     JSON.pretty_generate raw_result
                   else
                     raw_result.pretty_inspect
                   end
          puts result
        end
      end

      pre do |global_options, command, options, args|
        # Pre logic here
        # Return true to proceed; false to abort and not call the
        # chosen command
        # Use skips_pre before a command to skip this block
        # on that command only
        @asi = AsiBod::Asi.new(global_options)
        @bod = AsiBod::Bod.new(global_options)
      end

      post do |global_options, command, options, args|
        # Post logic here
        # Use skips_post before a command to skip this
        # block on that command only
      end

      on_error do |exception|
        # Error logic here
        # return false to skip default error handling
        true
      end

      exit run(ARGV)
    end
1219704
def dict(
        self, *, include: 'SetStr' = None, exclude: 'SetStr' = None, by_alias: bool = False, skip_defaults: bool = False
    ) -> 'DictStrAny':
        
        get_key = self._get_key_factory(by_alias)
        get_key = partial(get_key, self.fields)

        return_keys = self._calculate_keys(include=include, exclude=exclude, skip_defaults=skip_defaults)
        if return_keys is None:
            return {get_key(k): v for k, v in self._iter(by_alias=by_alias, skip_defaults=skip_defaults)}
        else:
            return {
                get_key(k): v for k, v in self._iter(by_alias=by_alias, skip_defaults=skip_defaults) if k in return_keys
            }
769878
def wo_resp(self, resp):
        
        if self._data is not None:
            resp['res'] = self.to_str(self._data)

        return self.wo_json(resp)
817932
def visit_dictcomp(self, node, parent):
        """"""
        newnode = nodes.DictComp(node.lineno, node.col_offset, parent)
        newnode.postinit(
            self.visit(node.key, newnode),
            self.visit(node.value, newnode),
            [self.visit(child, newnode) for child in node.generators],
        )
        return newnode