from parallels.plesk.source.web.utils.list_files.base import ListFilesBase


class ListFilesWebRPCAgent(ListFilesBase):
    def list_files(self, source):
        """
        :type source: parallels.plesk.source.web.connections.WebSource
        :rtype: list
        """
        web_rpc_runner = source.get_web_rpc_runner()
        return web_rpc_runner.get_dir_tree(source.get_absolute_files_root())

    def get_encoding(self, source):
        """Get encoding in which "list_files" function is expected to return file names.

        :type source: parallels.plesk.source.web.connections.WebSource
        :rtype: str
        """
        # All files with suspicious symbols are retrieved with filesystem runner
        return source.get_web_rpc_runner_encoding()
