@staticmethod
    def uri_to_pk(uri):
        if uri is None:
            return None

        # convert everything to lists
        multiple = not isinstance(uri, basestring)
        uris = uri if multiple else [uri]

        # handle all passed URIs
        converted = []
        for one_uri in uris:
            try:
                # hopefully /api/v1/<resource_name>/<pk>/
                converted.append(int(one_uri.split('/')[-2]))
            except (IndexError, __HOLE__):
                raise ValueError("URI %s could not be converted to PK integer." % one_uri)
            # convert back to original format
        return converted if multiple else converted[0]
dataset/ETHPy150Open mozilla/inventory/vendor-local/src/django-tastytools/tastytools/validation.py/FieldsValidation.uri_to_pk