

def _calculate_version(client, app_id, version):
    '\n    :param client: Marathon client\n    :type client: dcos.marathon.Client\n    :param app_id: The ID of the application\n    :type app_id: str\n    :param version: Relative or absolute version or None\n    :type version: str\n    :returns: The absolute version as an ISO8601 date-time\n    :rtype: str\n    '
    try:
        value = util.parse_int(version)
    except DCOSException:
        logger.exception('Unable to parse version %s', version)
        return version
    else:
        if (value < 0):
            value = ((- 1) * value)
            versions = client.get_app_versions(app_id, (value + 1))
            if (len(versions) <= value):
                msg = 'Application {!r} only has {!r} version(s).'
                raise DCOSException(msg.format(app_id, len(versions), value))
            else:
                return versions[value]
        else:
            raise DCOSException('Relative versions must be negative: {}'.format(version))

dataset/ETHPy150Open dcos/dcos-cli/cli/dcoscli/marathon/main.py _calculate_version/original