Get commands from etree
976455
def get_commands_from_xml(self, mission, role):
        """"""
        handlers = mission.findall(CommandParser.ns + "AgentSection" + "/" + CommandParser.ns + "AgentHandlers")
        if len(handlers) <= role:
            raise CommandHandlerException("Not enough agents sections in XML")
        commands = []
        self._command_hander(handlers[role], False, commands)
        return commands
71824
function getSubCommands(context, command) {
  var commands = cli.getMapping(context).requisition.system.commands;
  var subcommands = commands.getAll().filter(function(subcommand) {
    return subcommand.name.indexOf(command.name) === 0 &&
           subcommand.name !== command.name &&
           !subcommand.hidden;
  });

  subcommands.sort(function(c1, c2) {
    return c1.name.localeCompare(c2.name);
  });

  subcommands = subcommands.map(function(subcommand) {
    return subcommand.toJson();
  });

  return subcommands;
}
587597
def etree_to_string(tree):
        
        buff = BytesIO()
        tree.write(buff, xml_declaration=True, encoding='UTF-8')
        return buff.getvalue()
769086
def get_invocation_command(toolset, tool, user_provided_command = [],
                           additional_paths = [], path_last = False):
    
    assert isinstance(toolset, basestring)
    assert isinstance(tool, basestring)
    assert is_iterable_typed(user_provided_command, basestring)
    assert is_iterable_typed(additional_paths, basestring) or additional_paths is None
    assert isinstance(path_last, (int, bool))

    result = get_invocation_command_nodefault(toolset, tool,
                                              user_provided_command,
                                              additional_paths,
                                              path_last)

    if not result:
        if user_provided_command:
            result = user_provided_command[0]
        else:
            result = tool

    assert(isinstance(result, str))

    return result
188889
function getMatchingCommands(context, prefix) {
  var commands = cli.getMapping(context).requisition.system.commands;
  var reply = commands.getAll().filter(function(command) {
    if (command.hidden) {
      return false;
    }

    if (prefix && command.name.indexOf(prefix) !== 0) {
      // Filtered out because they don't match the search
      return false;
    }
    if (!prefix && command.name.indexOf(' ') != -1) {
      // We don't show sub commands with plain 'help'
      return false;
    }
    return true;
  });

  reply.sort(function(c1, c2) {
    return c1.name.localeCompare(c2.name);
  });

  reply = reply.map(function(command) {
    return command.toJson();
  });

  return reply;
}
1034854
def list_commands(self, ctx):
        """"""
        rv = []
        files = [_ for _ in next(os.walk(self.folder))[2] if not _.startswith("_") and _.endswith(".py")]
        for filename in files:
            rv.append(filename[:-3])
        rv.sort()
        return rv
523010
function getCommand(commandName) {
    return _.find(commands, function (command) {
      return _.includes(command.aliases, commandName);
    });
  }
1078051
def from_etree(root):
        
        cite_list = []
        citations = root.xpath('Citations/EventIVORN')
        if citations:
            description = root.xpath('Citations/Description')
            if description:
                description_text = description[0].text
            else:
                description_text = None
            for entry in root.Citations.EventIVORN:
                if entry.text:
                    cite_list.append(
                        Cite(ref_ivorn=entry.text,
                             cite_type=entry.attrib['cite'],
                             description=description_text)
                    )
                else:
                    logger.info(
                        'Ignoring empty citation in {}'.format(
                            root.attrib['ivorn']))
        return cite_list
220672
def get_phrases(self, ns=None, layer='syntax', cat_key='cat', cat_val='NP'):
        """"""
        if not ns:
            ns = self.ns

        for node_id in select_nodes_by_layer(self, '{0}:{1}'.format(ns, layer)):
            if self.node[node_id][self.ns+':'+cat_key] == cat_val:
                yield node_id
1307686
def get_treenodes(self):
        ""

        if not self.multitree:
            # get TreeNodes from Newick
            extractor = Newick2TreeNode(self.data[0].strip(), fmt=self.fmt)
        
            # extract one tree
            self.treenodes.append(extractor.newick_from_string())

        else:
            for tre in self.data:
                # get TreeNodes from Newick
                extractor = Newick2TreeNode(tre.strip(), fmt=self.fmt)
        
                # extract one tree
                self.treenodes.append(extractor.newick_from_string())
1293221
def const_get_tree(tree)
      if tree.size == 1
        Object.const_get(tree.first)
      else
        tree[1..-1].inject(Object.const_get(tree.first)) { |new_base, part| new_base.const_get(part) }
      end
    rescue
      raise ArgumentError, "Can't figure out command class name from path #{path} - tried #{tree}"
    end
434728
def get_external_commands(self):
        
        res = self.external_commands
        logger.debug("Get and clear external commands list: %s", res)
        self.external_commands = []
        return res
990094
def command_children(self, command):
        
        if not len(self.nodes):
            return

        commands = []
        for c in self.nodes:
            commands.append('[con_id="{}"] {};'.format(c.id, command))

        self._conn.command(' '.join(commands))
253591
def etree(self, data, root=None):
        ''''''
        result = self.list() if root is None else root
        if isinstance(data, (self.dict, dict)):
            for key, value in data.items():
                value_is_list = isinstance(value, (self.list, list))
                value_is_dict = isinstance(value, (self.dict, dict))
                # Add attributes and text to result (if root)
                if root is not None:
                    # Handle attribute prefixes (BadgerFish)
                    if self.attr_prefix is not None:
                        if key.startswith(self.attr_prefix):
                            key = key.lstrip(self.attr_prefix)
                            # @xmlns: {$: xxx, svg: yyy} becomes xmlns="xxx" xmlns:svg="yyy"
                            if value_is_dict:
                                raise ValueError('XML namespaces not yet supported')
                            else:
                                result.set(key, self._tostring(value))
                            continue
                    # Handle text content (BadgerFish, GData)
                    if self.text_content is not None:
                        if key == self.text_content:
                            result.text = self._tostring(value)
                            continue
                    # Treat scalars as text content, not children (GData)
                    if self.attr_prefix is None and self.text_content is not None:
                        if not value_is_dict and not value_is_list:
                            result.set(key, self._tostring(value))
                            continue
                # Add other keys as one or more children
                values = value if value_is_list else [value]
                for value in values:
                    elem = self.element(key)
                    if elem is None:
                        continue
                    result.append(elem)
                    # Treat scalars as text content, not children (Parker)
                    if not isinstance(value, (self.dict, dict, self.list, list)):
                        if self.text_content:
                            value = {self.text_content: value}
                    self.etree(value, root=elem)
        else:
            if self.text_content is None and root is not None:
                root.text = self._tostring(data)
            else:
                elem = self.element(self._tostring(data))
                if elem is not None:
                    result.append(elem)
        return result
525622
def get_commands(self, view=None):
    
    return self._get("commands", ApiCommand, True,
        params = view and dict(view=view) or None)
925127
def get_command(self, ctx, cmd_name):
        """"""
        path = "%s.%s" % (__name__, cmd_name)
        path = path.replace("-", "_")
        module = importlib.import_module(path)
        return getattr(module, 'cli')
262921
function getCommandHelps() {
        const cmds = {},
            topics = {},
            result = ['Registered commands:'];
        let keys = {};
        Object.keys(handlers).map((key) => {
            keys[key] = 1;
        });
        Object.keys(helpTopics).map((key) => {
            keys[key] = 1;
        });
        Object.keys(keys).map((key) => {
            if (handlers[key]) {
                cmds[key] = handlers[key].help;
                if (helpTopics[key]) {
                    cmds[key] += ' *';
                }
            } else {
                topics[key] = 'Extended help topic';
            }
        });
        keys = Object.keys(cmds);
        keys.sort();
        keys.forEach((cmd) => result.push(`${cmd}: ${cmds[cmd]}`));
        keys = Object.keys(topics);
        if (keys.length) {
            result.push('');
            result.push('Help Topics:');
            keys.sort();
            keys.forEach((topic) => result.push(`${topic}: ${topics[topic]}`));
        }
        return result.join('\n');
    }