extract the numeric version from the xml filename

def version_from_xml_filename(filename):
    "extract the numeric version from the xml filename"
    try:
        filename_parts = filename.split(os.sep)[-1].split('-')
    except AttributeError:
        return None
    if len(filename_parts) == 3:
        try:
            return int(filename_parts[-1].lstrip('v').rstrip('.xml'))
        except ValueError:
            return None
    else:
        return None