Try to extract an integer from a string, return the fallback if that's
    not possible.
767143
def parse_int(text, fallback=None):
    
    try:
        if isinstance(text, six.integer_types):
            return text
        elif isinstance(text, six.string_types):
            return int(text)
        else:
            return fallback
    except ValueError:
        return fallback
300079
def _try_get_string(dev, index, langid = None, default_str_i0 = "",
        default_access_error = "Error Accessing String"):
    
    if index == 0 :
        string = default_str_i0
    else:
        try:
            if langid is None:
                string = util.get_string(dev, index)
            else:
                string = util.get_string(dev, index, langid)
        except :
            string = default_access_error
    return string
1325553
def make_int(value, missing=-1):
    """"""
    if isinstance(value, six.string_types):
        if not value.strip():
            return missing
    elif value is None:
        return missing
    return int(value)
1144718
def neg_int(i):
    
    try:
        if isinstance(i, string_types):
            i = int(i)
        if not isinstance(i, int) or i > 0:
            raise Exception()
    except:
        raise ValueError("Not a negative integer")
    return i
630924
def int_or_str(v: Optional[str]) -> Union[None, int, str]:
    """"""
    if v is None:
        return
    try:
        return int(v)
    except ValueError:
        return v
747636
public int optInt(String name, int fallback) {
		Object object = opt(name);
		Integer result = JSON.toInteger(object);
		return result != null ? result : fallback;
	}
535618
def convert_string(string):
    
    if is_int(string):
        return int(string)
    elif is_float(string):
        return float(string)
    elif convert_bool(string)[0]:
        return convert_bool(string)[1]
    elif string == 'None':
        return None
    else:
        return string
1330919
def extract_value(self, string, key, inline_code=True):
        
        regex = r'\* ' + key + ': '
        if inline_code:
            regex = regex + '``(.*)``'
        else:
            regex = regex + '(.*)'
        value = re.findall(regex, string)
        if value:
            return value[0].replace('``', '')
        else:
            return False
90301
function(str, num) {
    if (isUndefined(num)) num = 1;
    var start = str.length - num < 0 ? 0 : str.length - num;
    return str.substr(start);
  }
823384
def parse_int(int_str):
    """"""
    int_str = int_str.replace(',', '')

    factor = __get_factor(int_str)
    if factor != 1:
        int_str = int_str[:-1]

    try:
        return int(int_str.replace(',', '')) * factor
    except ValueError:
        return None
313319
def get(self, key, fallback=None):
        """"""
        if key in self.headers:
            value = self.headers[key][0]
        else:
            value = fallback
        return value
712681
def try_int(s, default=None, minimum=None):
    
    if not s:
        return default
    try:
        val = int(s)
    except (TypeError, ValueError):
        raise InvalidNumber(s)
    if (minimum is not None) and (val < minimum):
        val = minimum
    return val
412061
public static Integer parseInt(final String str) {
        if (null != str) {
            try {
                return new Integer(Integer.parseInt(str.trim()));
            } catch (final Exception e) {
                // :IGNORE:
            }
        }
        return null;
    }
604369
private static Integer toInt(String str) {

        Integer num = null;
        try {
            num = Integer.parseInt(str);
        } catch (NumberFormatException ex) {
            log.severe(String.format("failed to convert str: %s to integer", str));
        }

        return num;
    }
272460
public Integer extractIntFromUsingGroup(String value, String regEx, int groupIndex) {
        Integer result = null;
        if (value != null) {
            Matcher matcher = getMatcher(regEx, value);
            if (matcher.matches()) {
                String intStr = matcher.group(groupIndex);
                result = convertToInt(intStr);
            }
        }
        return result;
    }
455777
def _fromstring(value):
        ''''''
        # NOTE: Is this even possible ?
        if value is None:
            return None

        # FIXME: In XML, booleans are either 0/false or 1/true (lower-case !)
        if value.lower() == 'true':
            return True
        elif value.lower() == 'false':
            return False

        # FIXME: Using int() or float() is eating whitespaces unintendedly here
        try:
            return int(value)
        except ValueError:
            pass

        try:
            # Test for infinity and NaN values
            if float('-inf') < float(value) < float('inf'):
                return float(value)
        except ValueError:
            pass

        return value
1228921
def from_string(cls, s):
        """"""
        for num, text in cls._STATUS2STR.items():
            if text == s:
                return cls(num)
        else:
            raise ValueError("Wrong string %s" % s)