Creates a list of commands from a list of ranges. Each range
        is converted to two commands: a start_* and a stop_*.
426884
def from_ranges(ranges, name, data_key, start_key='offset', length_key='length'):
        
        commands = []
        for r in ranges:
            data = r[data_key]
            start = r[start_key]
            stop = start + r[length_key]
            commands.extend(Command.start_stop(name, start, stop, data))
        return commands
1298433
def generate_instance_commands():
    ''' 

    '''
    from spython.instance import Instance

    from spython.main.base.logger import println
    from spython.main.instances import instances
    from spython.utils import run_command as run_cmd

    # run_command uses run_cmd, but wraps to catch error
    from spython.main.base.command import ( init_command, run_command )
    from spython.main.base.generate import RobotNamer
    from .start import start
    from .stop import stop

    Instance.RobotNamer = RobotNamer()
    Instance._init_command = init_command
    Instance.run_command = run_cmd
    Instance._run_command = run_command
    Instance._list = instances  # list command is used to get metadata
    Instance._println = println
    Instance.start = start     # intended to be called on init, not by user
    Instance.stop = stop

    # Give an instance the ability to breed :)
    Instance.instance = Instance
 
    return Instance
620498
def _translate_range(self, len_, start, end):
        
        if start < 0:
            start += len_
        start = max(0, min(start, len_))
        if end < 0:
            end += len_
        end = max(-1, min(end, len_ - 1))
        return start, end
1311246
def lrange(self, key, start, stop, *, encoding=_NOTSET):
        
        if not isinstance(start, int):
            raise TypeError("start argument must be int")
        if not isinstance(stop, int):
            raise TypeError("stop argument must be int")
        return self.execute(b'LRANGE', key, start, stop, encoding=encoding)
270209
def block_ranges(start_block, last_block, step=5):
    

    if last_block is not None and start_block > last_block:
        raise TypeError(
            "Incompatible start and stop arguments.",
            "Start must be less than or equal to stop.")

    return (
        (from_block, to_block - 1)
        for from_block, to_block
        in segment_count(start_block, last_block + 1, step)
    )
1372970
def cmd2list(cmd):
   ''' 
   '''
   p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
   stdout, stderr = p.communicate()
   if p.returncode != 0 and stderr != '':
      return "ERROR: %s\n"%(stderr)
   else:
      return stdout.split('\n')
473033
def range(self, start='-', stop='+', count=None):
        
        return self.database.xrange(self.key, start, stop, count)
1231049
def range(self, start, stop=None, step=1):
        
        self._assert_active()
        if stop is None:
            start, stop = 0, start
        full_list = range(start, stop, step)
        per_worker = len(full_list) // self._num_threads
        rem = len(full_list) % self._num_threads
        schedule = [
            per_worker + 1 if thread_idx < rem else per_worker
            for thread_idx in range(self._num_threads)
        ]
        # pylint: disable=undefined-variable
        start_idx = _functools.reduce(
            lambda x, y: x + y, schedule[: self.thread_num], 0
        )
        end_idx = start_idx + schedule[self._thread_num]
        return full_list[start_idx:end_idx]
160387
def ranges(self):
        
        steps = []
        for p in self._parameters:
            # inclusive range
            if p['parameter'] == 'filename':
                steps.append(p['names'])
            else:
                if p['step'] > 0:
                    start = p['start']
                    stop = p['stop']
                    if start > stop:
                        step = p['step']*-1
                    else:
                        step = p['step']
                    # nsteps = np.ceil(np.around(abs(start - stop), 4) / p['step'])
                    nsteps = self.nStepsForParam(p)
                    # print 'nsteps', np.around(abs(start - stop), 4), p['step']
                    # print 'start, stop, steps', start, stop, nsteps
                    step_tmp = np.linspace(start, start+step*(nsteps-2), nsteps-1)
                    # print 'step_tmp', step_tmp

                    # if step_tmp[-1] != stop:
                    step_tmp = np.append(step_tmp,stop)
                    # print 'step range', step_tmp

                    steps.append(np.around(step_tmp,4))
                else:
                    assert p['start'] == p['stop']
                    steps.append([p['start']])
        return steps
73803
def source_range_slices(start, end, nr_var_dict):
    

    return OrderedDict((k, slice(s,e,1))
        for k, (s, e)
        in source_range_tuple(start, end, nr_var_dict).iteritems())
733116
function range(begin, end, interval = 1) {
  var a = [];

  for (let i = begin; i < (begin+end); i += interval) {
    a.push(i);
  }

  return a;
}
500861
def list_commands(self, ctx):
        """"""
        commands = []
        for filename in os.listdir(self.path):
            if filename == '__init__.py':
                continue
            if filename.endswith('.py'):
                commands.append(filename[:-3].replace("_", "-"))
        commands.sort()
        return commands
1258756
def parse_range_list(ranges):
    
    if not ranges:
        return []
    parts = ranges.split(',')
    out = []
    for part in parts:
        fields = part.split('-', 1)
        if len(fields) == 2:
            start = int(fields[0])
            end = int(fields[1])
            out.extend(range(start, end + 1))
        else:
            out.append(int(fields[0]))
    return out
1285714
def from_list(commands):
    
    def subtrees(commands, level):
        if not commands:
            return

        acc = []
        parent, *commands = commands

        for command in commands:
            if command['level'] > level:
                acc.append(command)
            else:
                yield (parent, acc)
                parent = command
                acc.clear()
        yield (parent, acc)

    def walk(commands, level=0):
        return [
            {
                'description': key['description'],
                'children': walk(subtree, level + 1),
                'id': key['id']
            }
            for key, subtree in subtrees(commands, level)
        ]

    return walk(commands)
1318888
function mergeCommands(commands) {
  const cmds = filterCommands(commands);
  if (cmds.length === 0) {
    throw new Error('Expected at least one non-empty command');
  } else if (cmds.length === 1) {
    return cmds[0];
  } else {
    // Quote the arguments in each command and join them all using &&.
    const script = cmds.map(quote).join(' && ');
    return ['/bin/sh', '-c', script];
  }
}
716811
def macro_create(self, args: argparse.Namespace) -> None:
        """"""

        # Validate the macro name
        valid, errmsg = self.statement_parser.is_valid_command(args.name)
        if not valid:
            self.perror("Invalid macro name: {}".format(errmsg), traceback_war=False)
            return

        if args.name in self.get_all_commands():
            self.perror("Macro cannot have the same name as a command", traceback_war=False)
            return

        if args.name in self.aliases:
            self.perror("Macro cannot have the same name as an alias", traceback_war=False)
            return

        utils.unquote_redirection_tokens(args.command_args)

        # Build the macro value string
        value = args.command
        if args.command_args:
            value += ' ' + ' '.join(args.command_args)

        # Find all normal arguments
        arg_list = []
        normal_matches = re.finditer(MacroArg.macro_normal_arg_pattern, value)
        max_arg_num = 0
        arg_nums = set()

        while True:
            try:
                cur_match = normal_matches.__next__()

                # Get the number string between the braces
                cur_num_str = (re.findall(MacroArg.digit_pattern, cur_match.group())[0])
                cur_num = int(cur_num_str)
                if cur_num < 1:
                    self.perror("Argument numbers must be greater than 0", traceback_war=False)
                    return

                arg_nums.add(cur_num)
                if cur_num > max_arg_num:
                    max_arg_num = cur_num

                arg_list.append(MacroArg(start_index=cur_match.start(), number_str=cur_num_str, is_escaped=False))

            except StopIteration:
                break

        # Make sure the argument numbers are continuous
        if len(arg_nums) != max_arg_num:
            self.perror("Not all numbers between 1 and {} are present "
                        "in the argument placeholders".format(max_arg_num), traceback_war=False)
            return

        # Find all escaped arguments
        escaped_matches = re.finditer(MacroArg.macro_escaped_arg_pattern, value)

        while True:
            try:
                cur_match = escaped_matches.__next__()

                # Get the number string between the braces
                cur_num_str = re.findall(MacroArg.digit_pattern, cur_match.group())[0]

                arg_list.append(MacroArg(start_index=cur_match.start(), number_str=cur_num_str, is_escaped=True))
            except StopIteration:
                break

        # Set the macro
        result = "overwritten" if args.name in self.macros else "created"
        self.macros[args.name] = Macro(name=args.name, value=value, minimum_arg_count=max_arg_num, arg_list=arg_list)
        self.poutput("Macro '{}' {}".format(args.name, result))
327926
public static List<Long> starts(final Iterable<Range<Long>> ranges) {
        List<Long> starts = new ArrayList<Long>();
        for (Range<Long> range : ranges) {
            checkClosedOpen(range);
            starts.add(range.lowerEndpoint());
        }
        return starts;
    }