Manage short lists in pmxbot. See !stack help for more info
347742
def stack(nick, rest):
    ''
    atoms = [atom.strip() for atom in rest.split(' ', 1) if atom.strip()]
    if len(atoms) == 0:
        subcommand = "show"
        rest = ""
    elif len(atoms) == 1:
        subcommand = atoms[0]
        rest = ""
    else:
        subcommand, rest = atoms

    start = rest.find("[")
    finish = rest.rfind("]")
    sp = rest.find(" ")
    if (
        start != -1 and finish != -1 and start < finish and
        (sp == -1 or start < sp)
    ):
        topic, index = [atom.strip() for atom in rest[:finish].split("[", 1)]
        if not topic:
            topic = nick
        new_item = rest[finish + 1:].strip()
    else:
        topic = nick
        index = None
        new_item = rest.strip()

    if subcommand == "topics" or subcommand == "list":
        items = Stack.store.get_topics()
        items.sort()
    else:
        items = Stack.store.get_items(topic)
    try:
        indices = parse_index(index, items)
    except ValueError:
        return helpdoc["index"]

    if debug:
        print("SUBCOMMAND", subcommand.ljust(8), "TOPIC", topic.ljust(8),
              "INDICES", str(indices).ljust(12), "ITEM", new_item)

    if subcommand == "add":
        if not new_item:
            return ('!stack add <topic[index]> item: '
                    'You must provide an item to add.')

        if not indices:
            items.insert(0, new_item)
        else:
            for i in reversed(sorted(set(indices))):
                if i >= len(items):
                    items.append(new_item)
                else:
                    items.insert(i + 1, new_item)

        Stack.store.save_items(topic, items)
    elif subcommand == "pop":
        if not indices:
            indices = [0]

        popped_items = [items.pop(i) for i in reversed(sorted(set(indices)))
                        if len(items) > i >= 0]

        Stack.store.save_items(topic, items)

        return output([("-", item) for item in reversed(popped_items)],
                      "(none popped)", pop=True)
    elif subcommand == "show":
        if new_item:
            return helpdoc["show"]

        if not indices:
            indices = range(len(items))

        return output(
            [(i + 1, items[i]) for i in indices if len(items) > i >= 0]
        )
    elif subcommand == "shuffle":
        if not indices:
            random.shuffle(items)
        else:
            items = [items[i] for i in indices if len(items) > i >= 0]

        Stack.store.save_items(topic, items)

        return output(enumerate(items, 1))
    elif subcommand == "topics" or subcommand == "list":
        if new_item:
            return helpdoc["topics"]

        if not indices:
            indices = range(len(items))

        return output(
            [(i + 1, items[i]) for i in indices if len(items) > i >= 0]
        )
    elif subcommand == "help":
        return helpdoc.get(new_item, helpdoc["help"])
    else:
        return helpdoc["stack"]
129789
def _brief_print_list(lst, limit=7):
    """"""
    lst = list(lst)
    if len(lst) > limit:
        return _brief_print_list(lst[:limit//2], limit) + ', ..., ' + \
            _brief_print_list(lst[-limit//2:], limit)
    return ', '.join(["'%s'"%str(i) for i in lst])
630689
def mset_list(item, index, value):
    ''
    if isinstance(index, (int, slice)):
        item[index] = value
    else:
        map(item.__setitem__, index, value)
1099813
private void reportList(List collected, boolean doReport) {

        int size = collected.size();
        // now loop through all collected resources
        m_report.println(
            Messages.get().container(Messages.RPT_NUM_PAGES_1, new Integer(size)),
            I_CmsReport.FORMAT_HEADLINE);
        if (doReport) {
            int count = 1;

            Iterator i = collected.iterator();
            while (i.hasNext()) {
                String resName = (String)i.next();
                m_report.print(
                    org.opencms.report.Messages.get().container(
                        org.opencms.report.Messages.RPT_SUCCESSION_2,
                        String.valueOf(count++),
                        String.valueOf(size)),
                    I_CmsReport.FORMAT_NOTE);
                m_report.println(Messages.get().container(Messages.RPT_PROCESS_1, resName), I_CmsReport.FORMAT_NOTE);
            }
        }
        m_report.println(Messages.get().container(Messages.RPT_MERGE_PAGES_END_0), I_CmsReport.FORMAT_HEADLINE);
    }
217518
def list(ctx):
    """"""
    wva = get_wva(ctx)
    for subscription in wva.get_subscriptions():
        print(subscription.short_name)
129746
def SearchList(items, message="Select an item:", title='FontParts'):
    
    return dispatcher["SearchList"](items=items, message=message, title=title)
560782
def list(self, limit=None, offset=None):
        """"""
        return self._manager.list(limit=limit, offset=offset)
1259999
def list(self, limit=None, marker=None, name=None, visibility=None,
            member_status=None, owner=None, tag=None, status=None,
            size_min=None, size_max=None, sort_key=None, sort_dir=None,
            return_raw=False):
        
        uri = "/%s" % self.uri_base
        qs = utils.dict_to_qs(dict(limit=limit, marker=marker, name=name,
                visibility=visibility, member_status=member_status,
                owner=owner, tag=tag, status=status, size_min=size_min,
                size_max=size_max, sort_key=sort_key, sort_dir=sort_dir))
        if qs:
            uri = "%s?%s" % (uri, qs)
        return self._list(uri, return_raw=return_raw)
805711
def list_(ctx, search_string, reverse, backend, used, inactive):
    
    if not reverse:
        list_aliases(ctx, search_string, backend, used, inactive=inactive)
    else:
        show_mapping(ctx, search_string, backend)
872302
def macro_list(self, args: argparse.Namespace) -> None:
        """"""
        if args.name:
            for cur_name in utils.remove_duplicates(args.name):
                if cur_name in self.macros:
                    self.poutput("macro create {} {}".format(cur_name, self.macros[cur_name].value))
                else:
                    self.perror("Macro '{}' not found".format(cur_name), traceback_war=False)
        else:
            sorted_macros = utils.alphabetical_sort(self.macros)
            for cur_macro in sorted_macros:
                self.poutput("macro create {} {}".format(cur_macro, self.macros[cur_macro].value))
942165
def update_lists(self):
        
        print("{0}Update the package lists ?{1}".format(
            self.meta.color["GREEN"], self.meta.color["ENDC"]))
        print("=" * 79)
        if self.msg.answer() in ["y", "Y"]:
            Update().repository(["slack"])
1214348
def list_cab (archive, compression, cmd, verbosity, interactive):
    """"""
    cmdlist = [cmd, '-l']
    if verbosity > 0:
        cmdlist.append('-v')
    cmdlist.append(archive)
    return cmdlist
148418
def command_list(self):
        '''
        '''
        cmd = ['3dDeconvolve']

        cmd += ['-jobs',multiprocessing.cpu_count()]
        cmd += self.opts
        if(len(self.input_dsets)):
            cmd += ['-input'] + ['%s[%d..%d]' % (dset,self.partial[dset][0],self.partial[dset][1]) if dset in self.partial else dset for dset in self.input_dsets]
        else:
            cmd += ['-nodata']
            if self.reps:
                cmd += [str(self.reps)]
                if self.TR:
                    cmd += [str(self.TR)]
        if self.censor_file:
            censor_file = self.censor_file
            if self.partial:
                # This assumes only one dataset!
                with open(censor_file) as inf:
                    censor = inf.read().split()[self.partial.values()[0][0]:self.partial.values()[0][1]+1]
                    with tempfile.NamedTemporaryFile(delete=False) as f:
                        f.write('\n'.join(censor))
                        censor_file = f.name
                        self._del_files.append(f.name)
            cmd += ['-censor', censor_file]
        nfirst = self.nfirst
        if len(self.input_dsets) and self.input_dsets[0] in self.partial:
            nfirst -= self.partial[self.input_dsets[0]][0]
        if nfirst<0:
            nfirst = 0
        cmd += ['-nfirst',str(nfirst)]
        if self.mask:
            if self.mask=='auto':
                cmd += ['-automask']
            else:
                cmd += ['-mask',self.mask]
        cmd += ['-polort',str(self.polort)]

        stim_num = 1

        all_stims = list(self.decon_stims)
        all_stims += [DeconStim(stim,column_file=self.stim_files[stim],base=(stim in self.stim_base)) for stim in self.stim_files]
        for stim in self.stim_times:
            decon_stim = DeconStim(stim,times_file=self.stim_times[stim])
            decon_stim.times_model = self.models[stim] if stim in self.models else self.model_default
            decon_stim.AM1 = (stim in self.stim_am1)
            decon_stim.AM2 = (stim in self.stim_am2)
            decon_stim.base = (stim in self.stim_base)
            all_stims.append(decon_stim)

        if self.partial:
            for i in xrange(len(self.input_dsets)):
                if self.input_dsets[i] in self.partial:
                    new_stims = []
                    for stim in all_stims:
                        stim = stim.partial(self.partial[self.input_dsets[i]][0],self.partial[self.input_dsets[i]][1],i)
                        if stim:
                            new_stims.append(stim)
                    all_stims = new_stims

        cmd += ['-num_stimts',len(all_stims)]

        stimautoname = lambda d,s: 'stimfile_auto-%d-%s_' % (d,s.name) + str(datetime.datetime.now()).replace(" ","_").replace(":",".")

        for stim in all_stims:
            column_file = stim.column_file
            if stim.column!=None:
                column_file = stimautoname(stim_num,stim)
                with open(column_file,"w") as f:
                    f.write('\n'.join([str(x) for x in stim.column]))
            if column_file:
                cmd += ['-stim_file',stim_num,column_file,'-stim_label',stim_num,stim.name]
                if stim.base:
                    cmd += ['-stim_base',stim_num]
                stim_num += 1
                continue
            times_file = stim.times_file
            if stim.times!=None:
                times = list(stim.times)
                if '__iter__' not in dir(times[0]):
                    # a single list
                    times = [times]
                times_file = stimautoname(stim_num,stim)
                with open(times_file,"w") as f:
                    f.write('\n'.join([' '.join([str(x) for x in y]) if len(y)>0 else '*' for y in times]))
            if times_file:
                opt = '-stim_times'
                if stim.AM1:
                    opt = '-stim_times_AM1'
                if stim.AM2:
                    opt = '-stim_times_AM2'
                cmd += [opt,stim_num,times_file,stim.times_model]
                cmd += ['-stim_label',stim_num,stim.name]
                if stim.base:
                    cmd += ['-stim_base',stim_num]
                stim_num += 1

        strip_number = r'[-+]?(\d+)?\*?(\w+)(\[.*?\])?'
        all_glts = {}
        stim_names = [stim.name for stim in all_stims]
        if self.validate_glts:
            for glt in self.glts:
                ok = True
                for stim in self.glts[glt].split():
                    m = re.match(strip_number,stim)
                    if m:
                        stim = m.group(2)
                    if stim not in stim_names:
                        ok = False
                if ok:
                    all_glts[glt] = self.glts[glt]
        else:
            all_glts = self.glts

        cmd += ['-num_glt',len(all_glts)]

        glt_num = 1
        for glt in all_glts:
            cmd += ['-gltsym','SYM: %s' % all_glts[glt],'-glt_label',glt_num,glt]
            glt_num += 1

        if self.bout:
            cmd += ['-bout']
        if self.tout:
            cmd += ['-tout']
        if self.vout:
            cmd += ['-vout']
        if self.rout:
            cmd += ['-rout']

        if self.errts:
            cmd += ['-errts', self.errts]

        if self.prefix:
            cmd += ['-bucket', self.prefix]

        return [str(x) for x in cmd]
88915
def _list(self, foldername="INBOX", reverse=False, since=None):
        
        folder = self.folder \
            if foldername == "INBOX" \
            else self._getfolder(foldername)

        def sortcmp(d):
            try:
                return d[1].date
            except:
                return -1

        lst = folder.items() if not since else folder.items_since(since)
        sorted_lst = sorted(lst, key=sortcmp, reverse=1 if reverse else 0)
        itemlist = [(folder, key, msg) for key,msg in sorted_lst]
        return itemlist
184599
def _list_collections(self, sock_info, slave_okay, session,
                          read_preference, **kwargs):
        """"""

        coll = self.get_collection(
            "$cmd", read_preference=read_preference)
        if sock_info.max_wire_version > 2:
            cmd = SON([("listCollections", 1),
                       ("cursor", {})])
            cmd.update(kwargs)
            with self.__client._tmp_session(
                    session, close=False) as tmp_session:
                cursor = self._command(
                    sock_info, cmd, slave_okay,
                    read_preference=read_preference,
                    session=tmp_session)["cursor"]
                return CommandCursor(
                    coll,
                    cursor,
                    sock_info.address,
                    session=tmp_session,
                    explicit_session=session is not None)
        else:
            match = _INDEX_REGEX
            if "filter" in kwargs:
                match = {"$and": [_INDEX_REGEX, kwargs["filter"]]}
            dblen = len(self.name.encode("utf8") + b".")
            pipeline = [
                {"$project": {"name": {"$substr": ["$name", dblen, -1]},
                              "options": 1}},
                {"$match": match}
            ]
            cmd = SON([("aggregate", "system.namespaces"),
                       ("pipeline", pipeline),
                       ("cursor", kwargs.get("cursor", {}))])
            cursor = self._command(sock_info, cmd, slave_okay)["cursor"]
            return CommandCursor(coll, cursor, sock_info.address)
294369
def cmd_fw_list(self, args):
        ''''''
        stuff = self.filtered_rows_from_args(args)
        if stuff is None:
            return
        (filtered, remainder) = stuff
        print("")
        print(" seq platform frame    major.minor.patch releasetype latest git-sha format")
        for row in filtered:
            print("{seq:>5} {platform:<13} {frame:<10} {version:<10} {releasetype:<9} {latest:<6} {git-sha} {format}".format(**row))
271737
def list(gandi, limit, step):
    """"""
    output_keys = ['id', 'type', 'step']

    options = {
        'step': step,
        'items_per_page': limit,
        'sort_by': 'date_created DESC'
    }

    result = gandi.oper.list(options)
    for num, oper in enumerate(reversed(result)):
        if num:
            gandi.separator_line()
        output_generic(gandi, oper, output_keys)

    return result