Filter serves by tags
176058
function(readPreference, servers) {
  if (readPreference.tags == null) return servers;
  var filteredServers = [];
  var tagsArray = Array.isArray(readPreference.tags) ? readPreference.tags : [readPreference.tags];

  // Iterate over the tags
  for (var j = 0; j < tagsArray.length; j++) {
    var tags = tagsArray[j];

    // Iterate over all the servers
    for (var i = 0; i < servers.length; i++) {
      var serverTag = servers[i].lastIsMaster().tags || {};

      // Did we find the a matching server
      var found = true;
      // Check if the server is valid
      for (var name in tags) {
        if (serverTag[name] !== tags[name]) {
          found = false;
        }
      }

      // Add to candidate list
      if (found) {
        filteredServers.push(servers[i]);
      }
    }
  }

  // Returned filtered servers
  return filteredServers;
}
48866
def filter_by_name_or_id_or_tag(self, query_string, queryset = None):
        
        assert self.Model.NAME_FIELD, \
            'NAME_FIELD is missing on model %s' % self.Model.__name__
        assert self.Model.ID_FIELD, \
            'ID_FIELD is missing on model %s' % self.Model.__name__
        assert self.Model.TAG_FIELD, \
            'TAG_FIELD is missing on model %s' % self.Model.__name__

        filter_args = {}
        name, uuid, tag = self._parse_as_name_or_id_or_tag(query_string)
        if name is not None:
            filter_args[self.Model.NAME_FIELD] = name
        if uuid is not None:
            filter_args[self.Model.ID_FIELD+'__startswith'] = uuid
        if tag is not None:
            filter_args[self.Model.TAG_FIELD] = tag
        if queryset is None:
            queryset = self.Model.objects.all()
        return queryset.filter(**filter_args)
59124
def filter_issues_for_tags(newer_tag, older_tag)
      filtered_pull_requests = filter_by_tag(@pull_requests, newer_tag)
      filtered_issues        = delete_by_time(@issues, "actual_date", older_tag, newer_tag)

      newer_tag_name = newer_tag.nil? ? nil : newer_tag["name"]

      if options[:filter_issues_by_milestone]
        # delete excess irrelevant issues (according milestones). Issue #22.
        filtered_issues = filter_by_milestone(filtered_issues, newer_tag_name, @issues)
        filtered_pull_requests = filter_by_milestone(filtered_pull_requests, newer_tag_name, @pull_requests)
      end
      [filtered_issues, filtered_pull_requests]
    end
726832
def filter(parser, token):
    
    bits = token.contents.split(' ')
    return FilterTag(bits[1], bits[2:])
1270927
def markdown(*args, &block)
      filter(Rake::Pipeline::Web::Filters::MarkdownFilter, *args, &block)
    end
23465
function filterTags(tags, content) {
  if (!tags) {
    return content;
  }
  const $ = cheerio.load(content, { xmlMode: false });
  const tagOperations = tags.map(tag => ({
    // Trim leading + or -, replace * with .*, add ^ and $
    tagExp: `^${escapeRegExp(tag.replace(/^(\+|-)/g, '')).replace(/\\\*/, '.*')}$`,
    // Whether it is makes tags visible or hides them
    isHidden: tag.startsWith('-'),
  }));
  $('[tags]').each((i, element) => {
    $(element).attr('hidden', true);
    $(element).attr('tags').split(' ').forEach((tag) => {
      tagOperations.forEach((tagOperation) => {
        if (!tag.match(tagOperation.tagExp)) {
          return;
        }
        if (tagOperation.isHidden) {
          $(element).attr('hidden', true);
        } else {
          $(element).removeAttr('hidden');
        }
      });
    });
  });
  $('[hidden]').remove();
  return $.html();
}
1132735
def filter(self, table, users, filter_string):
        """"""
        q = filter_string.lower()
        return [user for user in users
                if (q in user.name.lower() or
                    q in (getattr(user, 'email', None) or '').lower())]
201313
function add_filter( $tag, $function_to_add, $priority = WP_FS__DEFAULT_PRIORITY, $accepted_args = 1 ) {
            $this->_logger->entrance( $tag );

            add_filter( $this->get_action_tag( $tag ), $function_to_add, $priority, $accepted_args );
        }
815747
public function filterByTag($tag = '')
    {
        $db = Loader::db();
        $this->filter(false, "( fv.fvTags like ".$db->qstr("%\n".$tag."\n%")."  )");
    }
153169
def filter
      if content = Rails.cache.read(cache_path, :raw => true)
        cache_hit(content)
      else
        cache_miss
      end
    end
124762
def list_tags(tags):
    """"""
    tags_sorted = sorted(list(tags.items()), key=operator.itemgetter(0))
    tag_sec_spacer = ""
    c = 1
    ignored_keys = ["Name", "aws:ec2spot:fleet-request-id"]
    pad_col = {1: 38, 2: 49}
    for k, v in tags_sorted:
        # if k != "Name":
        if k not in ignored_keys:
            if c < 3:
                padamt = pad_col[c]
                sys.stdout.write("  {2}{0}:{3} {1}".
                                 format(k, v, C_HEAD2, C_NORM).ljust(padamt))
                c += 1
                tag_sec_spacer = "\n"
            else:
                sys.stdout.write("{2}{0}:{3} {1}\n".format(k, v, C_HEAD2,
                                                           C_NORM))
                c = 1
                tag_sec_spacer = ""
    print(tag_sec_spacer)
1185290
def tags_from_hit(self, tag_ids):
        
        ids = []
        for t in tag_ids.split():
            t = t.strip()
            try:
                t = int(t)
            except ValueError:
                pass
            else:
                ids.append(t)

        if not ids:
            return []

        return Tag.query.filter(Tag.id.in_(ids)).all()
1052537
def custom_filter_tags(self, value, search):
        """"""
        if not isinstance(value, list):
            value = value.split(',')

        filters = [Q('match', **{'tags': item}) for item in value]
        search = search.query('bool', must=filters)

        return search
247649
def query_tags(tags, hrefs=nil, timeout=120)
      cmd = { :name => :query_tags, :tags => tags }
      cmd[:hrefs] = hrefs unless hrefs.nil? || hrefs.empty?
      response = blocking_request(cmd, timeout)
      begin
        result = OperationResult.from_results(load(response, "Unexpected response #{response.inspect}"))
        raise TagError.new("Query tags failed: #{result.content}") unless result.success?
        return result.content
      rescue
        raise TagError.new("Query tags failed: #{response.inspect}")
      end
    end
370819
def search_tags(self, tags):
        
        qs = self.filter(tags__name__in=tags).order_by('file').distinct()
        return qs
993991
function has_filter( $tag, $function_to_check = false ) {
            $this->_logger->entrance( $tag );

            return has_filter( $this->get_action_tag( $tag ), $function_to_check );
        }
1084379
def _filter(self, text, context, encoding):
        """"""

        content = []
        self.current_encoding = encoding
        self.line_num = 1
        self.prev_line = -1
        self.leading = ''
        self.block_comments = []
        self.line_comments = []

        self.find_content(text)
        self.extend_src(content, context)

        return content