Removes surrounding whitespace, leading separator and normalize.
435346
def _NormalizePath(path):
  """"""
  # TODO(emrekultursay): Calling os.path.normpath "may change the meaning of a
  # path that contains symbolic links" (e.g., "A/foo/../B" != "A/B" if foo is a
  # symlink). This might cause trouble when matching against loaded module
  # paths. We should try to avoid using it.
  # Example:
  #  > import symlink.a
  #  > symlink.a.__file__
  #  symlink/a.py
  #  > import target.a
  #  > starget.a.__file__
  #  target/a.py
  # Python interpreter treats these as two separate modules. So, we also need to
  # handle them the same way.
  return os.path.normpath(path.strip().lstrip(os.sep))
517180
def collapse_whitespace(text):
    
    if text is None:
        return None
    if hasattr(text, 'xpath'):
        text = text.xpath('string()')
    text = re.sub('\s+', ' ', text)
    return text.strip()
671494
def clean(string):
    '''  '''
    # manual fixes in the source
    # 24/1.png
    # 9/1.png
    # 3/1.png
    #if ')' in string:  # fix in the source data
        #string = string.split(')')[0] + ')'  # remove trailing garbage
    return (string
            .replace('_', '')
            .replace('-', '')
            .replace('—', '')
            .replace('.', '')
            .replace('=', '')
            .replace('\u2018',"'")  # LEFT SINGLE QUOTATION MARK
            .replace('\u2019', "'")  # RIGHT SINGLE QUOTATION MARK
            .strip())
679257
private String filterWhitespace(String text) {
        text = text.replace("\n", " ");
        text = text.replaceAll(" {2,}", " ");
        text = XmlEscape.escape(text);
        return text.trim();
    }
77528
private static String trimLeadingWhitespace(String string) {
        if (string.isEmpty()) {
            return string;
        }

        int start = 0;
        char c;

        for (int i = 0; i < string.length(); i++) {
            c = string.charAt(i);
            if (!Character.isWhitespace(c)) {
                start = i;
                break;
            }
        }

        if (start == 0) {
            return string;
        }

        return string.substring(start);
    }
1017537
function normalizeFontSize(value) {
	// "Strip leading and trailing whitespace from value."
	//
	// Cheap hack, not following the actual algorithm.
	value = value.trim();

	// "If value is not a valid floating point number, and would not be a valid
	// floating point number if a single leading "+" character were stripped,
	// abort these steps and do nothing."
	if (!/^[-+]?[0-9]+(\.[0-9]+)?([eE][-+]?[0-9]+)?$/.test(value)) {
		return null;
	}

	var mode;

	// "If the first character of value is "+", delete the character and let
	// mode be "relative-plus"."
	if (value[0] == "+") {
		value = value.slice(1);
		mode = "relative-plus";
	// "Otherwise, if the first character of value is "-", delete the character
	// and let mode be "relative-minus"."
	} else if (value[0] == "-") {
		value = value.slice(1);
		mode = "relative-minus";
	// "Otherwise, let mode be "absolute"."
	} else {
		mode = "absolute";
	}

	// "Apply the rules for parsing non-negative integers to value, and let
	// number be the result."
	//
	// Another cheap hack.
	var num = parseInt(value);

	// "If mode is "relative-plus", add three to number."
	if (mode == "relative-plus") {
		num += 3;
	}

	// "If mode is "relative-minus", negate number, then add three to it."
	if (mode == "relative-minus") {
		num = 3 - num;
	}

	// "If number is less than one, let number equal 1."
	if (num < 1) {
		num = 1;
	}

	// "If number is greater than seven, let number equal 7."
	if (num > 7) {
		num = 7;
	}

	// "Set value to the string here corresponding to number:" [table omitted]
	value = {
		1: "xx-small",
		2: "small",
		3: "medium",
		4: "large",
		5: "x-large",
		6: "xx-large",
		7: "xxx-large"
	}[num];

	return value;
}
364843
def clean(cls, cnpj):
        
        """
        if isinstance(cnpj, six.string_types):
            cnpj = int(re.sub('[^0-9]', '', cnpj))

        return '{0:014d}'.format(cnpj)
463155
function(str) {
    return trim(str).replace(/([\r\n\s　])+/g, function(match, whitespace) {
      return whitespace === '　' ? whitespace : ' ';
    });
  }
796430
def fix_whitespace(tokens, start, result):
    """"""
    for e in result:
        for child in e.iter():
            child.text = child.text.replace(' , ', ', ')
            for hyphen in HYPHENS:
                child.text = child.text.replace(' %s ' % hyphen, '%s' % hyphen)
            child.text = re.sub(r'- (.) -', r'-\1-', child.text)
    return result
985469
def collapse_whitespace(message):
    """"""
    return u' '.join(map(lambda s: s.strip(),
                         filter(None, message.strip().splitlines())))
992031
def clean(ctx, text):
    
    text = conversions.to_string(text, ctx)
    return ''.join([c for c in text if ord(c) >= 32])
574185
def clean_ns(tag):
    """"""
    if '}' in tag:
        split = tag.split('}')
        return split[0].strip('{'), split[-1]
    return '', tag
1084937
public void removeTrailingWhitespaces()
    {
        int last = -1;
        for (int i = text.length() - 1; i >= 0; i--)
        {
            if (isWhitespace(text.charAt(i)))
                last = i;
            else
                break;
        }
        if (last != -1)
        {
            text = text.substring(0, last);
            textStart = 0;
            textEnd = last;
        }
    }
400195
def strip_spaces(value, sep=None, join=True):
    """"""
    value = value.strip()
    value = [v.strip() for v in value.split(sep)]
    join_sep = sep or ' '
    return join_sep.join(value) if join else value
43924
function trimTrailingWhitespace(index, nextTag) {
    for (var endTag = null; index >= 0 && _canTrimWhitespace(endTag); index--) {
      var str = buffer[index];
      var match = str.match(/^<\/([\w:-]+)>$/);
      if (match) {
        endTag = match[1];
      }
      else if (/>$/.test(str) || (buffer[index] = collapseWhitespaceSmart(str, null, nextTag, options))) {
        break;
      }
    }
  }
773194
def _strip_space(x):
    """"""
    r = repr(x)
    space_repr = '{!r}.element('.format(x.space)
    if r.startswith(space_repr) and r.endswith(')'):
        r = r[len(space_repr):-1]
    return r
1198842
def clean(cls, cpf):
        
        """
        if isinstance(cpf, six.string_types):
            cpf = int(re.sub('[^0-9]', '', cpf))

        return '{0:011d}'.format(cpf)