return method by the length of string
        :param string: string
        :return: method
356731
def _str_parser(string):
        
        if not any(c.isalpha() for c in string):
            _string = string[:19]
            _length = len(_string)
            if _length > 10:
                return BaseParser.parse_datetime
            elif 6 <= _length <= 10:
                if ':' in _string:
                    return BaseParser.parse_time
                else:
                    return BaseParser.parse_date
            elif _length < 6:
                return BaseParser.parse_time
            else:
                return BaseParser.parse_special
        else:
            return BaseParser.__parse_not_only_str
1198414
def method(value, arg):
    
    if hasattr(value, str(arg)):
        return getattr(value, str(arg))
    return "[%s has no method %s]" % (value, arg)
362615
def limit_value_string_length(value):
    
    if isinstance(value, string_types) and len(value) > constants.MAX_VALUE_LABEL_TEXT_LENGTH:
        value = value[:constants.MAX_VALUE_LABEL_TEXT_LENGTH] + "..."
        final_string = " " + value + " "
    elif isinstance(value, (dict, list)) and len(str(value)) > constants.MAX_VALUE_LABEL_TEXT_LENGTH:
        value_text = str(value)[:constants.MAX_VALUE_LABEL_TEXT_LENGTH] + "..."
        final_string = " " + value_text + " "
    else:
        final_string = " " + str(value) + " "

    return final_string
975095
def _add_to_docstring(string):
    '''

    '''
    def wrapper(method):
        if method.__doc__ is not None:
            method.__doc__ += string
        else:
            method.__doc__ = string
        return method
    return wrapper
681696
def from_string(cls, string):
        
        cls.TYPE.setParseAction(cls.make)
        try:
            return cls.TYPE.parseString(string, parseAll=True)[0]
        except ParseException:
            log.error("Failed to parse '{0}'".format(string))
            raise
591761
def str_func(name):
    
    def func(mapping, bind, values):
        for v in values:
            if isinstance(v, six.string_types):
                v = getattr(v, name)()
            yield v
    return func
431696
function(method){
            method = this.string(method);
            if(methods.indexOf(method.toLowerCase()) < 0){
                throw new TypeError('a method in [' + methods.join(', ') + '] is expected, but ' + method + ' given');
            }
            return method.toLowerCase();
        }
187720
def fixed_length_split(s, width):
    
    # 使用正则的方法
    # import re
    # split = re.findall(r'.{%s}' % width, string)
    return [s[x: x + width] for x in range(0, len(s), width)]
252230
static
	public String trim(String string){
		int length = string.length();

		int trimmedLength = length;

		while(trimmedLength > 0){
			char c = string.charAt(trimmedLength - 1);

			if(!Character.isWhitespace(c)){
				break;
			}

			trimmedLength--;
		}

		if(trimmedLength < length){
			string = string.substring(0, trimmedLength);
		}

		return string;
	}
577373
def readString(self):
        
        length, is_reference = self._readLength()

        if is_reference:
            result = self.context.getString(length)

            return self.context.getStringForBytes(result)

        if length == 0:
            return ''

        result = self.stream.read(length)
        self.context.addString(result)

        return self.context.getStringForBytes(result)
414976
public static short stringToShort(String string) {
        string = string.trim();
        if (Checker.isNumber(string)) {
            return Short.parseShort(string);
        }
        return -1;
    }
661390
def find_in_line(line):  # type: (str) -> Optional[str]
    
    if not line:
        return None

    for method in [find_by_ast, find_version_by_string_lib, find_version_by_regex]:
        by = method(line)
        by = validate_string(by)
        if by:
            return by
    return None
1180928
def from_string(cls, alg_str):
        
        try:
            return cls(int(alg_str[1]) - 1, ord(alg_str[0]) - 97)
        except ValueError as e:
            raise ValueError("Location.from_string {} invalid: {}".format(alg_str, e))
1022725
def truncate(string, width):
    
    if len(string) > width:
        return string[:width-3] + '...'
    else:
        return string.ljust(width)
723596
def get_methods_by_name(self, name):
        

        return (m for m in self.methods if m.get_name() == name)
835126
def get_from_string(cls, string_condition):
        

        if string_condition == 'PodScheduled':
            return cls.SCHEDULED
        elif string_condition == 'Ready':
            return cls.READY
        elif string_condition == 'Initialized':
            return cls.INITIALIZED
        elif string_condition == 'Unschedulable':
            return cls.UNSCHEDULABLE
        elif string_condition == 'ContainersReady':
            return cls.CONTAINERS_READY

        return cls.UNKNOWN
77359
function stringTrim (str) {
  return str && str.trim ? str.trim() : stringTrimRight(stringTrimLeft(str))
}