def strip_base_dir(filename, base_dir):
    """Strip base directory from filename if it starts there.

    >>> strip_base_dir('/path/to/base/relpath/to/file',
    ...                '/path/to/base/')
    'relpath/to/file'

    >>> strip_base_dir('/path/to/somewhere/else/relpath/to/file',
    ...                '/path/to/base/')
    '/path/to/somewhere/else/relpath/to/file'

    """
    if filename.startswith(base_dir):
        filename = filename[len(base_dir):]
    return filename
