view env/lib/python3.9/site-packages/galaxy/tool_util/locations/__init__.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
line wrap: on
line source

import tempfile
from abc import (
    ABCMeta,
    abstractmethod,
    abstractproperty,
)


class ToolLocationResolver(metaclass=ABCMeta):
    """Parse a URI-like string and return a ToolSource object."""

    @abstractproperty
    def scheme(self):
        """Short label for the type of location resolver and URI scheme."""

    @abstractmethod
    def get_tool_source_path(self, uri_like):
        """Return a local path for the uri_like string."""

    def _temp_path(self, uri_like):
        """Create an abstraction for this so we can configure and cache later."""
        with tempfile.NamedTemporaryFile(suffix=uri_like.split("/")[-1], delete=False) as temp:
            return temp.name