Skip to content

MacOSBase64EncodeCommand

Base classes

Name Children Inherits
Base64EncodeCommand
anyenv.os_commands.base
Base class for base64 encode commands.

⋔ Inheritance diagram

graph TD
  3213617532["base64_encode.MacOSBase64EncodeCommand"]
  3600911348["base.Base64EncodeCommand"]
  925645236["abc.ABC"]
  2751680898["builtins.object"]
  3600911348 --> 3213617532
  925645236 --> 3600911348
  2751680898 --> 925645236

🛈 DocStrings

Bases: Base64EncodeCommand

macOS base64 encode command implementation.

Source code in src/anyenv/os_commands/base64_encode.py
class MacOSBase64EncodeCommand(Base64EncodeCommand):
    """macOS base64 encode command implementation."""

    def create_command(self, path: str) -> str:
        """Generate macOS base64 command.

        Args:
            path: Path to file to encode

        Returns:
            The base64 command string
        """
        # macOS base64 uses -i for input file
        return f"base64 -i {sh_path(path)}"

    def parse_command(self, output: str) -> bytes:
        """Parse macOS base64 output.

        Args:
            output: Raw base64 encoded output

        Returns:
            Decoded bytes
        """
        cleaned = output.replace("\n", "").replace("\r", "").strip()
        return base64.b64decode(cleaned)

create_command

create_command(path: str) -> str

Generate macOS base64 command.

Parameters:

Name Type Description Default
path str

Path to file to encode

required

Returns:

Type Description
str

The base64 command string

Source code in src/anyenv/os_commands/base64_encode.py
def create_command(self, path: str) -> str:
    """Generate macOS base64 command.

    Args:
        path: Path to file to encode

    Returns:
        The base64 command string
    """
    # macOS base64 uses -i for input file
    return f"base64 -i {sh_path(path)}"

parse_command

parse_command(output: str) -> bytes

Parse macOS base64 output.

Parameters:

Name Type Description Default
output str

Raw base64 encoded output

required

Returns:

Type Description
bytes

Decoded bytes

Source code in src/anyenv/os_commands/base64_encode.py
def parse_command(self, output: str) -> bytes:
    """Parse macOS base64 output.

    Args:
        output: Raw base64 encoded output

    Returns:
        Decoded bytes
    """
    cleaned = output.replace("\n", "").replace("\r", "").strip()
    return base64.b64decode(cleaned)

:fa-brands-github: Show source on GitHub