Tests a filter which simply a joker, i.e. a value presence test
541456
def _comparator_presence(_, tested_value):
    
    # The filter value is a joker : simple presence test
    if tested_value is None:
        return False
    elif hasattr(tested_value, "__len__"):
        # Refuse empty values
        # pylint: disable=C1801
        return len(tested_value) != 0

    # Presence validated
    return True
897788
function(filter, choice) {
      var choices = [];
      for (var i = 0; i < filter.choices.length; i++) {
        choices.push({
          label: filter.choices[i].label,
          action: filter.name,
          value: filterValueToChoiceValue(filter.choices[i].value, choice),
          default: filter.choices[i].value === filter.def
        });
      };
      return choices;
    }
1061366
def _is_local_filter(filter_block):
    """"""
    # We need the "result" value of this function to be mutated within the "visitor_fn".
    # Since we support both Python 2 and Python 3, we can't use the "nonlocal" keyword here:
    # https://www.python.org/dev/peps/pep-3104/
    # Instead, we use a dict to store the value we need mutated, since the "visitor_fn"
    # can mutate state in the parent scope, but not rebind variables in it without "nonlocal".
    # TODO(predrag): Revisit this if we drop support for Python 2.
    result = {
        'is_local_filter': True
    }
    filter_predicate = filter_block.predicate

    def visitor_fn(expression):
        """Expression visitor function that looks for uses of non-local fields."""
        non_local_expression_types = (ContextField, ContextFieldExistence)

        if isinstance(expression, non_local_expression_types):
            result['is_local_filter'] = False

        # Don't change the expression.
        return expression

    filter_predicate.visit_and_update(visitor_fn)

    return result['is_local_filter']
336249
private Object filterValue(Object value)
   {
      if (value instanceof Boolean && !((Boolean) value).booleanValue())
      {
         value = null;
      }
      if (value instanceof String && ((String) value).isEmpty())
      {
         value = null;
      }
      if (value instanceof Double && ((Double) value).doubleValue() == 0.0)
      {
         value = null;
      }
      if (value instanceof Integer && ((Integer) value).intValue() == 0)
      {
         value = null;
      }
      if (value instanceof Duration && ((Duration) value).getDuration() == 0.0)
      {
         value = null;
      }

      return value;
   }
1202506
function filterFunc(inputValue, optionValue) {
  if (inputValue && optionValue) {
    return optionValue.toLowerCase().indexOf(inputValue.toLowerCase()) > -1;
  }

  return false;
}
380316
function isMatchPresent(regex, text, test = false) {
  return test ? regex.test(text) : text.match(regex)
}
1009354
def _create_filter(self, condition):
        
        # "Normal" comparison operators?
        comparison = re.match(r"^(%s)(<[>=]?|>=?|!=|~)(.*)$" % self.ident_re, condition)
        if comparison:
            name, comparison, values = comparison.groups()
            if values and values[0] in "+-":
                raise FilterError("Comparison operator cannot be followed by '%s' in '%s'" % (values[0], condition))
            values = self.COMPARISON_OPS[comparison] % values
        else:
            # Split name from value(s)
            try:
                name, values = condition.split('=', 1)
            except ValueError:
                if self.default_field:
                    name, values = self.default_field, condition
                else:
                    raise FilterError("Field name missing in '%s' (expected '=')" % condition)

        # Try to find field definition
        field = self.lookup(name)
        if not field:
            raise FilterError("Unknown field %r in %r" % (name, condition))
        if field.get("matcher") is None:
            raise FilterError("Field %r cannot be used as a filter" % (name,))

        # Make filters from values (split on commas outside of /…/)
        filters = []
        split_values = re.findall(r'(!?/[^/]*/|[^,]+)(?:,|$)', values) if values else ['']
        if not split_values:
            raise FilterError("Internal Error: Cannot split %r into match values" % (values,))

        for value in split_values:
            wrapper = None
            if value.startswith('!'):
                wrapper = NegateFilter
                value = value[1:]
            field_matcher = field["matcher"](name, value)
            filters.append(wrapper(field_matcher) if wrapper else field_matcher)

        # Return filters
        return CompoundFilterAny(filters) if len(filters) > 1 else filters[0]
209812
def filter_simple(filter):
    
    def function_getter(function):
        if isinstance(function, Filter):
            function.add_filter(filter)

            return function
        else:
            return Filter(
                filter=filter,
                callback=function,
            )

    return function_getter
1009721
function cleanupFilter(filter) {
  let filterToUse = filter;
  if (
    filterToUse.selectedFilter === "inList" &&
    typeof filterToUse.filterValue === "number"
  ) {
    filterToUse = {
      ...filterToUse,
      filterValue: filterToUse.filterValue.toString()
    };
  }
  if (filterToUse.selectedFilter === "inList") {
    filterToUse = {
      ...filterToUse,
      filterValue: filterToUse.filterValue.replace(/, |,/g, ".")
    };
  }
  return filterToUse;
}
533322
def do_or_fake_filter( value, formatter ):
    
    if not value:
        value = Faker.getGenerator().format( formatter )
    return value
297945
def _match_filters(parameter, filters=None):
        """"""
        for filter_obj in (filters or []):
            key = filter_obj['Key']
            option = filter_obj.get('Option', 'Equals')
            values = filter_obj.get('Values', [])

            what = None
            if key == 'Type':
                what = parameter.type
            elif key == 'KeyId':
                what = parameter.keyid

            if option == 'Equals'\
                    and not any(what == value for value in values):
                return False
            elif option == 'BeginsWith'\
                    and not any(what.startswith(value) for value in values):
                return False
        # True if no false match (or no filters at all)
        return True
48234
function filter(options, includes, root, filepath, stat) {
  var paths = path.relative(root, filepath).split(path.sep);
  // always include test/tests directory when running jpm test
  if (options.command === "test") {
    if (/^tests?$/.test(paths[0])) {
      if (paths.length === 1 && stat.isDirectory()) {
        return true;
      }
      if (paths.length > 1) {
        return true;
      }
    }
  }
  return includes.indexOf(filepath) !== -1;
}
561148
def filter_not_empty_values(value):
    """"""
    if not value:
        return None
    data = [x for x in value if x]
    if not data:
        return None
    return data
524847
function filterInPlace(a, fn, ctxt) {
  for (var i = 0; i < a.length; i++) {
    if (!fn.call(ctxt, a[i], i, a)) {
      a.splice(i--, 1);
    }
  }
  return a;
}
386749
def is_api_filter(self, filter_field):
        """"""
        if self.filter_type == 'server':
            for choice in self.filter_choices:
                if (choice[0] == filter_field and len(choice) > 2 and
                        choice[2]):
                    return True
        return False
1062194
def sanitize_filter_value(value, depth)
      depth += 1
      if depth >= MAX_FILTER_DEPTH
        '[MAX_FILTER_DEPTH_REACHED]'
      elsif value.is_a?(Array)
        value.map { |array_value| sanitize_filter_value(array_value, depth) }
      elsif value.is_a?(Hash)
        sanitize_filter_hash(value, depth)
      else
        '?'
      end
    end
621582
def _comparator_approximate(filter_value, tested_value):
    
    lower_filter_value = filter_value.lower()

    if is_string(tested_value):
        # Lower case comparison
        return _comparator_eq(lower_filter_value, tested_value.lower())

    elif hasattr(tested_value, "__iter__"):
        # Extract a list of strings
        new_tested = [
            value.lower() for value in tested_value if is_string(value)
        ]

        if _comparator_eq(lower_filter_value, new_tested):
            # Value found in the strings
            return True

    # Compare the raw values
    return _comparator_eq(filter_value, tested_value) or _comparator_eq(
        lower_filter_value, tested_value
    )