CLI action "run editor for filters list".
541747
def do_filter(config, config_dir):
    
    if not os.path.exists(config_dir):
        print "Configuration '{}' does not exist.".format(config)
        exit(1)    

    editor = os.environ["EDITOR"]

    config_filter = os.path.join(config_dir, 'filter')
    call([editor, config_filter])
    print "Filter configuration has been updated."
1072237
async def execute_filter(filter_: FilterObj, args):
    
    if filter_.is_async:
        return await filter_.filter(*args, **filter_.kwargs)
    else:
        return filter_.filter(*args, **filter_.kwargs)
122978
def _parse_cli_filters(filters):
        
        parsed_filters = []
        for filter_entry in filters:
            filter_parts = re.match('^Name=(?P<name_value>[^,]+),Values=\[?(?P<key_values>[^\]]+)\]?', filter_entry)
            parsed_filters.append({
                'Name': filter_parts.group('name_value'),
                'Values': filter_parts.group('key_values').split(',')
            })
        return parsed_filters
796898
def run():
    """"""
    import optparse

    parser = optparse.OptionParser(usage=r"%prog [<options>] [file ...]")
    parser.add_option(
        "-p", "--spread", type="float", default=3.0, help="Rainbow spread"
    )
    parser.add_option(
        "-F", "--freq", type="float", default=0.1, help="Rainbow frequency"
    )
    parser.add_option("-S", "--seed", type="int", default=0, help="Rainbow seed")
    parser.add_option(
        "-a",
        "--animate",
        action="store_true",
        default=False,
        help="Enable psychedelics",
    )
    parser.add_option(
        "-d", "--duration", type="int", default=12, help="Animation duration"
    )
    parser.add_option(
        "-s", "--speed", type="float", default=20.0, help="Animation speed"
    )
    parser.add_option(
        "-f",
        "--force",
        action="store_true",
        default=False,
        help="Force colour even when stdout is not a tty",
    )

    parser.add_option(
        "-3", action="store_const", dest="mode", const=8, help="Force 3 bit colour mode"
    )
    parser.add_option(
        "-4",
        action="store_const",
        dest="mode",
        const=16,
        help="Force 4 bit colour mode",
    )
    parser.add_option(
        "-8",
        action="store_const",
        dest="mode",
        const=256,
        help="Force 8 bit colour mode",
    )

    parser.add_option(
        "-c",
        "--charset-py2",
        default="utf-8",
        help="Manually set a charset to convert from, for python 2.7",
    )

    options, args = parser.parse_args()
    options.os = random.randint(0, 256) if options.seed == 0 else options.seed
    options.mode = options.mode or detect_mode()

    lolcat = LolCat(mode=options.mode)

    if not args:
        args = ["-"]

    for filename in args:
        if filename == "-":
            lolcat.cat(sys.stdin, options)
        else:
            try:
                with open(filename, "r") as handle:
                    lolcat.cat(handle, options)
            except IOError as error:
                sys.stderr.write(str(error) + "\n")
552519
function edit(inst, list, index, argv, event, fin) {
    return function editCallback(err, data) {
        if (err) return fin(err);
        list[index] = data;
        return fin(null, list);
    };
}
488871
def edit_and_execute(event):
    
    buff = event.current_buffer

    buff.open_in_editor(event.cli)
    buff.accept_action.validate_and_handle(event.cli, buff)
1321042
def _filter_commands(ctx, commands=None):
    """"""
    lookup = getattr(ctx.command, 'commands', {})
    if not lookup and isinstance(ctx.command, click.MultiCommand):
        lookup = _get_lazyload_commands(ctx.command)

    if commands is None:
        return sorted(lookup.values(), key=lambda item: item.name)

    names = [name.strip() for name in commands.split(',')]
    return [lookup[name] for name in names if name in lookup]
1027631
def run_filter_calculation(self):
        """"""
        inputs = {
            'cif': self.inputs.cif,
            'code': self.inputs.cif_filter,
            'parameters': self.inputs.cif_filter_parameters,
            'metadata': {
                'options': self.inputs.options.get_dict(),
            }
        }

        calculation = self.submit(CifFilterCalculation, **inputs)
        self.report('submitted {}<{}>'.format(CifFilterCalculation.__name__, calculation.uuid))

        return ToContext(cif_filter=calculation)
532717
function (list, e, item) {
			this.options.todos.push(item);
			// Reset the filter so that you always see your new todo
			this.options.state.attr('filter', '');
		}
715132
def __update_filter(self):
        
        filters = list()
        if self.__date_filter:
            filters.append(self.__date_filter)
        if self.__text_filter:
            filters.append(self.__text_filter)
        self.document_controller.display_filter = ListModel.AndFilter(filters)
1164043
function start($mode = null)
    {
        // register UI objects
        $this->rc->output->add_handlers(array(
            'filterslist'      => array($this, 'filters_list'),
            'filtersetslist'   => array($this, 'filtersets_list'),
            'filterframe'      => array($this, 'filter_frame'),
            'filterform'       => array($this, 'filter_form'),
            'filtersetform'    => array($this, 'filterset_form'),
            'filterseteditraw' => array($this, 'filterset_editraw'),
        ));

        // connect to managesieve server
        $error = $this->connect($_SESSION['username'], $this->rc->decrypt($_SESSION['password']));

        // load current/active script
        if (!$error) {
            // Get list of scripts
            $list = $this->list_scripts();

            // reset current script when entering filters UI (#1489412)
            if ($this->rc->action == 'plugin.managesieve') {
                $this->rc->session->remove('managesieve_current');
            }

            if ($mode != 'vacation') {
                if (!empty($_GET['_set']) || !empty($_POST['_set'])) {
                    $script_name = rcube_utils::get_input_value('_set', rcube_utils::INPUT_GPC, true);
                }
                else if (!empty($_SESSION['managesieve_current'])) {
                    $script_name = $_SESSION['managesieve_current'];
                }
            }

            $error = $this->load_script($script_name);
        }

        // finally set script objects
        if ($error) {
            switch ($error) {
                case rcube_sieve::ERROR_CONNECTION:
                case rcube_sieve::ERROR_LOGIN:
                    $this->rc->output->show_message('managesieve.filterconnerror', 'error');
                    break;

                default:
                    $this->rc->output->show_message('managesieve.filterunknownerror', 'error');
                    break;
            }

            // reload interface in case of possible error when specified script wasn't found (#1489412)
            if ($script_name !== null && !empty($list) && !in_array($script_name, $list)) {
                $this->rc->output->command('reload', 500);
            }

            // to disable 'Add filter' button set env variable
            $this->rc->output->set_env('filterconnerror', true);
            $this->script = array();
        }
        else {
            $this->exts = $this->sieve->get_extensions();
            $this->init_script();
            $this->rc->output->set_env('currentset', $this->sieve->current);
            $_SESSION['managesieve_current'] = $this->sieve->current;
        }

        $this->rc->output->set_env('raw_sieve_editor', $this->rc->config->get('managesieve_raw_editor', true));

        return $error;
    }
302220
def run_filters(type)
      halted = false
      tracker = env['scorched.executed_filters'] ||= {before: Set.new, after: Set.new}
      filters[type].reject { |f| tracker[type].include?(f) }.each do |f|
        unless check_for_failed_condition(f[:conditions]) || (halted && !f[:force])
          tracker[type] << f
          halted = true unless run_filter(f)
        end
      end
      !halted
    end
589971
def do_edit(self, args):
        """"""
        if 'EDITOR' not in os.environ:
            print('*** $EDITOR not set')
        else:
            path = os.path.join(utils.CONFIG_DIR, 'sql')
            cmd = os.environ['EDITOR']
            try:
                os.system(cmd + ' ' + path)
                if os.path.exists(path):
                    with open(path, 'r') as f:
                        sql = f.read()
                        if sql:
                            self.default(sql)
            finally:
                if os.path.exists(path):
                    os.remove(path)
895158
private function runFilters()
    {
        foreach ($this->filterObjects as $filter) {
            $filter_key = $filter->getKey();

            // Execute the filter method if enabled
            if ($this->request->has($filter_key)) {
                $filter_option = ucfirst(preg_replace('/[^a-z0-9]/i', ' ', $this->request->input($filter_key)));

                $filter_key = ucfirst(preg_replace('/[^a-z0-9]/i', ' ', $filter_key));

                if (!in_array($filter_option, $this->filters[$filter_key])) {
                    continue;
                }

                $filter_method = 'filter'.Str::studly($filter_key).Str::studly($filter_option);

                if (method_exists($this, $filter_method)) {
                    $this->$filter_method();
                }
            }
        }
    }
103494
def _build_filter_list(self, filters):
        
        i = 0
        for (filter_type, values) in filters.items():
            if isinstance(values[0], str):
                for line in values[0].split('\n'):
                    line = line.strip()
                    yield "{filter_name} {filter_type} {filter_value}".format(
                        filter_name="filter" + str(i),
                        filter_type=filter_type,
                        filter_value='"{}" {}'.format(line, " ".join([str(v) for v in values[1:]]))).strip()
                    i += 1
            else:
                yield "{filter_name} {filter_type} {filter_value}".format(
                    filter_name="filter" + str(i),
                    filter_type=filter_type,
                    filter_value=" ".join([str(v) for v in values]))
                i += 1
171452
def _filter(self, commands, parser):
        
        resized = set()
        commands2 = []
        for command in reversed(commands):
            if command[0] == 'SHADERS':
                convert = parser.convert_shaders()
                if convert:
                    shaders = self._convert_shaders(convert, command[2:])
                    command = command[:2] + shaders
            elif command[1] in resized:
                if command[0] in ('SIZE', 'DATA'):
                    continue  # remove this command
            elif command[0] == 'SIZE':
                resized.add(command[1])
            commands2.append(command)
        return list(reversed(commands2))
583446
def edit(self):
        
        subprocess.call("{0} {1}".format(self.meta.editor,
                                         self.config_file), shell=True)