def is_previous_version(version, target_version):
    """
    Compare version with a target version.

    Able to compare versions with integers only.

    Args:
        version(str): version to compare
        target_version(str): version to compare with

    Returns:
        bool: True if versions are the same or if the version is older than the target version.

    """
    if version is None or target_version is None:
        return True
    if version.isdigit() and target_version.isdigit():
        return int(version) <= int(target_version)
    if '.' in version and len(version.split('.')) == len(target_version.
        split('.')):
        ver = version.split('.')
        for index, target in enumerate(target_version.split('.')):
            is_digit = ver[index].isdigit() and target.isdigit()
            if is_digit and int(ver[index]) < int(target):
                return True
        if is_digit:
            return int(ver[index]) <= int(target)
    if version:
        return version == target_version
    return False
