def size_for(s):
    """
    This function takes a string representing an amount of bytes and converts
    it into the int corresponding to that many bytes. The string can be a plain
    int which gets directly converted to that number of bytes or can end in a specifier
    such as 100k. This indicates it is 100 kilobytes and so is translated into 100000

    for example
    size_for('1000') == 1000
    size_for('10m') == 10000000
    size_for('1000k') == size_for('1m')
    etc.

    The valid specifiers are
    k = kilo (1000)
    m = mega (1000000)
    g = giga (1000000000)
    """
    s = s.strip()
    try:
        return int(s)
    except ValueError:
        pass
    d = s[-1]
    v = s[:-1]
    m = 1
    if d == 'k':
        m = 1000
    elif d == 'm':
        m = 1000000
    elif d == 'g':
        m = 1000000000
    return int(v) * m