Skip to content

base

Class info

Classes

Name Children Inherits
ShareResult
anyenv.text_sharing.base
Result of a text sharing operation.
    TextSharer
    anyenv.text_sharing.base
    Base class for text sharing services.

    🛈 DocStrings

    Base class for text sharing services.

    ShareResult dataclass

    Result of a text sharing operation.

    Source code in src/anyenv/text_sharing/base.py
    @dataclass
    class ShareResult:
        """Result of a text sharing operation."""
    
        url: str
        """URL to access the shared content."""
    
        raw_url: str | None = None
        """Direct URL to raw content, if available."""
    
        delete_url: str | None = None
        """URL to delete the content, if available."""
    
        id: str | None = None
        """Provider-specific ID of the shared content."""
    

    delete_url class-attribute instance-attribute

    delete_url: str | None = None
    

    URL to delete the content, if available.

    id class-attribute instance-attribute

    id: str | None = None
    

    Provider-specific ID of the shared content.

    raw_url class-attribute instance-attribute

    raw_url: str | None = None
    

    Direct URL to raw content, if available.

    url instance-attribute

    url: str
    

    URL to access the shared content.

    TextSharer

    Bases: ABC

    Base class for text sharing services.

    Source code in src/anyenv/text_sharing/base.py
    class TextSharer(abc.ABC):
        """Base class for text sharing services."""
    
        @property
        @abc.abstractmethod
        def name(self) -> str:
            """Name of the sharing service."""
    
        @abc.abstractmethod
        async def share(
            self,
            content: str,
            *,
            title: str | None = None,
            syntax: str | None = None,
            visibility: Visibility = "unlisted",
            expires_in: int | None = None,
        ) -> ShareResult:
            """Share text content.
    
            Args:
                content: The text content to share
                title: Optional title/filename for the content
                syntax: Syntax highlighting hint (e.g. "python", "markdown")
                visibility: Visibility level (not all providers support all levels)
                expires_in: Expiration time in seconds (not supported by all providers)
    
            Returns:
                ShareResult with URL and metadata
            """
    
        def share_sync(
            self,
            content: str,
            *,
            title: str | None = None,
            syntax: str | None = None,
            visibility: Visibility = "unlisted",
            expires_in: int | None = None,
        ) -> ShareResult:
            """Synchronous version of share."""
            from anyenv import run_sync
    
            async def wrapper() -> ShareResult:
                return await self.share(
                    content,
                    title=title,
                    syntax=syntax,
                    visibility=visibility,
                    expires_in=expires_in,
                )
    
            return run_sync(wrapper())
    

    name abstractmethod property

    name: str
    

    Name of the sharing service.

    share abstractmethod async

    share(
        content: str,
        *,
        title: str | None = None,
        syntax: str | None = None,
        visibility: Visibility = "unlisted",
        expires_in: int | None = None,
    ) -> ShareResult
    

    Share text content.

    Parameters:

    Name Type Description Default
    content str

    The text content to share

    required
    title str | None

    Optional title/filename for the content

    None
    syntax str | None

    Syntax highlighting hint (e.g. "python", "markdown")

    None
    visibility Visibility

    Visibility level (not all providers support all levels)

    'unlisted'
    expires_in int | None

    Expiration time in seconds (not supported by all providers)

    None

    Returns:

    Type Description
    ShareResult

    ShareResult with URL and metadata

    Source code in src/anyenv/text_sharing/base.py
    @abc.abstractmethod
    async def share(
        self,
        content: str,
        *,
        title: str | None = None,
        syntax: str | None = None,
        visibility: Visibility = "unlisted",
        expires_in: int | None = None,
    ) -> ShareResult:
        """Share text content.
    
        Args:
            content: The text content to share
            title: Optional title/filename for the content
            syntax: Syntax highlighting hint (e.g. "python", "markdown")
            visibility: Visibility level (not all providers support all levels)
            expires_in: Expiration time in seconds (not supported by all providers)
    
        Returns:
            ShareResult with URL and metadata
        """
    

    share_sync

    share_sync(
        content: str,
        *,
        title: str | None = None,
        syntax: str | None = None,
        visibility: Visibility = "unlisted",
        expires_in: int | None = None,
    ) -> ShareResult
    

    Synchronous version of share.

    Source code in src/anyenv/text_sharing/base.py
    def share_sync(
        self,
        content: str,
        *,
        title: str | None = None,
        syntax: str | None = None,
        visibility: Visibility = "unlisted",
        expires_in: int | None = None,
    ) -> ShareResult:
        """Synchronous version of share."""
        from anyenv import run_sync
    
        async def wrapper() -> ShareResult:
            return await self.share(
                content,
                title=title,
                syntax=syntax,
                visibility=visibility,
                expires_in=expires_in,
            )
    
        return run_sync(wrapper())