def _parse_path(self, path):
        parts = split_path(path)

        if not parts:
            return None, []

        resource = parts.pop(0)
        if resource == 'remote':
            if not parts:
                raise MissingHostName("Provide remote host name")

            host = parts.pop(0)
            if host not in self._resources['remote']:
                self._resources['remote'][host] = RemoteResources(host)

            manager = self._resources['remote'][host]
        elif resource == 'templates':
            if not parts:
                raise MissingTemplateCategory("Provide template category")

            category = parts.pop(0)
            if category not in self._resources['templates']:
                raise InvalidPath("Invalid template category: {}".format(category))

            manager = self._resources['templates'][category]
        else:
            try:
                manager = self._resources[resource]
            except KeyError:
                raise InvalidPath("Invalid resource: {}".format(resource))

        return manager, parts
dataset/ETHPy150Open m110/grafcli/grafcli/resources/resources.py/Resources._parse_path/original