/*
Test if a value matches the ECMAScript definition of trimmable whitespace.
352311
function isSpace(c)
{
	return (c === 0x20) ||
	    (c >= 0x0009 && c <= 0x000d) ||
	    (c === 0x00a0) ||
	    (c === 0x1680) ||
	    (c === 0x180e) ||
	    (c >= 0x2000 && c <= 0x200a) ||
	    (c === 0x2028) ||
	    (c === 0x2029) ||
	    (c === 0x202f) ||
	    (c === 0x205f) ||
	    (c === 0x3000) ||
	    (c === 0xfeff);
}
1010521
function compatible(value, descriptor) {
  if (!value) {
    // If we're a null, then we can't validate.
    return false;
  } else if (!descriptor) {
    return true;
  }

  const descriptorType = typeof descriptor;
  if (descriptorType === 'string') {
    return typeof value === descriptor;
  } else if (descriptorType === 'function') {
    return descriptor(value);
  } else if (descriptorType === 'object') {
    let matched = true;
    Object.keys(descriptor).forEach((key) => {
      const fromValue = value[key];
      const fromDescriptor = descriptor[key];
      if (!compatible(fromValue, fromDescriptor)) {
        matched = false;
      }
    });
    return matched;
  }

  throw new Error('Unknown descriptor type: ' + descriptorType);
}
828213
function validateArraySpacing (node) {
      if (node.elements.length === 0) {
        return
      }

      var first = context.getFirstToken(node)
      var second = context.getFirstToken(node, 1)
      var penultimate = context.getLastToken(node, 1)
      var last = context.getLastToken(node)

      var openingBracketMustBeSpaced =
      (options.objectsInArraysException && second.value === '{') ||
      (options.arraysInArraysException && second.value === '[') ||
      (options.singleElementException && node.elements.length === 1)
        ? !options.spaced : options.spaced

      var closingBracketMustBeSpaced =
      (options.objectsInArraysException && penultimate.value === '}') ||
      (options.arraysInArraysException && penultimate.value === ']') ||
      (options.singleElementException && node.elements.length === 1)
        ? !options.spaced : options.spaced

      // we only care about evenly spaced things
      if (options.either) {
        // newlines at any point means return
        if (!isSameLine(first, last)) {
          return
        }

        // confirm that the object expression/literal is spaced evenly
        if (!isEvenlySpacedAndNotTooLong(node, [first, second], [penultimate, last])) {
          context.report(node, 'Expected consistent spacing')
        }

        return
      }

      if (isSameLine(first, second)) {
        if (openingBracketMustBeSpaced && !isSpaced(first, second)) {
          reportRequiredBeginningSpace(node, first)
        }
        if (!openingBracketMustBeSpaced && isSpaced(first, second)) {
          reportNoBeginningSpace(node, first)
        }
      }

      if (isSameLine(penultimate, last)) {
        if (closingBracketMustBeSpaced && !isSpaced(penultimate, last)) {
          reportRequiredEndingSpace(node, last)
        }
        if (!closingBracketMustBeSpaced && isSpaced(penultimate, last)) {
          reportNoEndingSpace(node, last)
        }
      }
    }
1232715
public boolean isMatched(String value)
    {
        if (value == null)
            return false;
        if ((_match != null)) {
            for (int i = 0; i < _match.length; i++) {
                if (value.equals(_match[i]))
                    return true;
            }
        }
        else {
            if (_defaultSelections != null) {
                return (_defaultSelections.contains(value));
            }
        }

        return false;

    }
717956
@Trivial
    private static String collapseWhitespace(String value) {
        final int length = value.length();
        for (int i = 0; i < length; ++i) {
            if (isSpace(value.charAt(i))) {
                return collapse0(value, i, length);
            }
        }
        return value;
    }
410067
function checkRegExp(test) {
  if (typeof test === 'string' && test[0] === '/') {
    var matchs = test.match(/^\/(.+)\/([igm]*)$/);
    if (matchs) {
      test = new RegExp(matchs[1], matchs[2]);
    }
  }
  return test;
}
636568
function extractWhitespaces(ast /*, options*/) {
  const TYPE_WHITESPACE = "whitespace";
  return ast.map(node => {
    if (!node.children) {
      return node;
    }

    if (
      node.children.length === 0 ||
      (node.children.length === 1 &&
        node.children[0].type === "text" &&
        node.children[0].value.trim().length === 0)
    ) {
      return node.clone({
        children: [],
        hasDanglingSpaces: node.children.length !== 0
      });
    }

    const isWhitespaceSensitive = isWhitespaceSensitiveNode(node);
    const isIndentationSensitive = isIndentationSensitiveNode(node);

    return node.clone({
      isWhitespaceSensitive,
      isIndentationSensitive,
      children: node.children
        // extract whitespace nodes
        .reduce((newChildren, child) => {
          if (child.type !== "text" || isWhitespaceSensitive) {
            return newChildren.concat(child);
          }

          const localChildren = [];

          const [, leadingSpaces, text, trailingSpaces] = child.value.match(
            /^(\s*)([\s\S]*?)(\s*)$/
          );

          if (leadingSpaces) {
            localChildren.push({ type: TYPE_WHITESPACE });
          }

          const ParseSourceSpan = child.sourceSpan.constructor;

          if (text) {
            localChildren.push({
              type: "text",
              value: text,
              sourceSpan: new ParseSourceSpan(
                child.sourceSpan.start.moveBy(leadingSpaces.length),
                child.sourceSpan.end.moveBy(-trailingSpaces.length)
              )
            });
          }

          if (trailingSpaces) {
            localChildren.push({ type: TYPE_WHITESPACE });
          }

          return newChildren.concat(localChildren);
        }, [])
        // set hasLeadingSpaces/hasTrailingSpaces and filter whitespace nodes
        .reduce((newChildren, child, i, children) => {
          if (child.type === TYPE_WHITESPACE) {
            return newChildren;
          }

          const hasLeadingSpaces =
            i !== 0 && children[i - 1].type === TYPE_WHITESPACE;
          const hasTrailingSpaces =
            i !== children.length - 1 &&
            children[i + 1].type === TYPE_WHITESPACE;

          return newChildren.concat(
            Object.assign({}, child, {
              hasLeadingSpaces,
              hasTrailingSpaces
            })
          );
        }, [])
    });
  });
}
1007398
function checkForIrregularWhitespace(node, ignoreTokens) {
            const text = sourceCode.text.slice(node.range[0], node.range[1])
            let match = undefined

            /**
             * Check whether the index is in ignore location.
             * @param {number} index The index.
             * @returns {boolean} `true` if the index is in ignore location.
             */
            function isIgnoreLocation(index) {
                return (
                    ignoreTokens.find(
                        t => t.range[0] <= index && index < t.range[1]
                    ) ||
                    templateTokens.find(
                        t => t.range[0] <= index && index < t.range[1]
                    )
                )
            }

            while ((match = IRREGULAR_WHITESPACE.exec(text)) !== null) {
                const index = node.range[0] + match.index

                if (isIgnoreLocation(index)) {
                    continue
                }

                const code = `0000${sourceCode.text[index]
                    .charCodeAt(0)
                    .toString(16)}`
                    .slice(-4)
                    .toUpperCase()
                context.report({
                    loc: sourceCode.getLocFromIndex(index),
                    messageId: "unexpected",
                    data: { code },
                    fix: defineWhitespaceFix(index),
                })
            }

            while ((match = IRREGULAR_LINE_TERMINATORS.exec(text)) !== null) {
                const index = node.range[0] + match.index

                if (isIgnoreLocation(index)) {
                    continue
                }

                const code = `0000${sourceCode.text[index]
                    .charCodeAt(0)
                    .toString(16)}`
                    .slice(-4)
                    .toUpperCase()
                context.report({
                    loc: sourceCode.getLocFromIndex(index),
                    messageId: "unexpected",
                    data: { code },
                    fix: defineLineTerminatorsFix(index),
                })
            }
        }
1097318
def safe_trim(qty_as_string):
    '''
    
    '''
    qty_formatted = qty_as_string
    if '.' in qty_as_string:
        # only affect numbers with decimals
        while True:
            if qty_formatted[-1] == '0' and qty_formatted[-2] != '.':
                qty_formatted = qty_formatted[:-1]
            else:
                break

    return qty_formatted
935471
def normalize_whitespace(self, value):
        """"""
        if isinstance(value, unicode):
            return u" ".join(
                x for x in re.split(r'\s+', value, flags=re.UNICODE) if
                len(x)
            )
        else:
            return " ".join(value.split())
896380
function checkWhitelist(str, whitelist, context) {
    if (whitelist.indexOf(str) === -1) {
        throw new ImplementationError(
            'Invalid "' + str + '" (allowed: ' + whitelist.join(', ') + ')' + context.errorContext
        );
    }
    return str;
}
849452
def _no_trailing_whitespace(relative_path, contents, linter_options):
    """
    del relative_path
    del linter_options

    trailing_whitespace = re.compile(r"(?<![ \t\r\n])[ \t]+$")

    for index, line in enumerate(contents):
        for space in trailing_whitespace.finditer(line):
            assert space.end() == len(line) - 1
            return LinterFailure("Trailing whitespace",
                                 index + 1,
                                 line[:space.start()] + line[space.end():])
550044
function(matches, index, tokens, regexValue) {
      var i = tokens.length;

      while (--i >= 0) {
        var token = tokens[i];
        var type = token.type;

        if (type === _Comment ||
            type === _WhiteSpace ||
            type === _LineTerminator) {
          continue;
        }

        var value = token.value;
        if (type === _Punctuator) {
          if (value === ')') {
            if (this.isValidRegExpPrefix(tokens, i + 1)) {
              break;
            }
          } else if (regexPrefixRe.test(value)) {
            break;
          }
        } else if ((type === _Keyword && regexPrefixRe.test(value)) ||
                   (type === _Template && value.slice(-2) === '${')) {
          break;
        }

        var parts = regexValue.match(tokenizeNotRegExpRe);
        splice.apply(matches, [index, 1].concat(parts));
        return true;
      }
      return false;
    }
732408
function isValid(desc) {
      if (desc.validator) {
        if (desc.validator instanceof RegExp) {
          return !desc.validator.test(value);
        }

        return !desc.validator(value);
      }
      return false;
    }
96498
def check_convert_string(obj, name=None,
                             no_leading_trailing_whitespace=True,
                             no_whitespace=False,
                             no_newline=True,
                             whole_word=False,
                             min_len=1,
                             max_len=0):
        """"""
        if not name:
            name = 'Argument'
        obj = ensure_unicode(obj, name=name)
        if no_whitespace:
            if _PATTERN_WHITESPACE.match(obj):
                raise ValueError('%s cannot contain whitespace' % name)
        elif no_leading_trailing_whitespace and _PATTERN_LEAD_TRAIL_WHITESPACE.match(obj):
            raise ValueError('%s contains leading/trailing whitespace' % name)
        if (min_len and len(obj) < min_len) or (max_len and len(obj) > max_len):
            raise ValueError('%s too short/long (%d/%d)' % (name, min_len, max_len))
        if whole_word:
            if not _PATTERN_WORD.match(obj):
                raise ValueError('%s can only contain alphanumeric (unicode) characters, numbers and the underscore'
                                 % name)
        # whole words cannot contain newline so additional check not required
        elif no_newline and '\n' in obj:
            raise ValueError('%s cannot contain line breaks' % name)
        return obj
265602
def string_matches_sans_whitespace(self, str1, str2_fuzzy_whitespace):
        """"""
        str2_fuzzy_whitespace = re.sub('\s+', '\s*', str2_fuzzy_whitespace)
        return re.search(str2_fuzzy_whitespace, str1) is not None
700941
function interElementWhiteSpace(node) {
  var value

  if (node && typeof node === 'object' && node.type === 'text') {
    value = node.value || ''
  } else if (typeof node === 'string') {
    value = node
  } else {
    return false
  }

  return value.replace(re, '') === ''
}