Skip to content

MacOSFileInfoCommand

Base classes

Name Children Inherits
FileInfoCommand
anyenv.os_commands.base
Base class for file info commands.

⋔ Inheritance diagram

graph TD
  2737525930["file_info.MacOSFileInfoCommand"]
  3903279879["base.FileInfoCommand"]
  925645236["abc.ABC"]
  2751680898["builtins.object"]
  3903279879 --> 2737525930
  925645236 --> 3903279879
  2751680898 --> 925645236

🛈 DocStrings

Bases: FileInfoCommand

macOS file info command implementation using ls -la.

Source code in src/anyenv/os_commands/file_info.py
class MacOSFileInfoCommand(FileInfoCommand):
    """macOS file info command implementation using ls -la."""

    def create_command(self, path: str) -> str:
        """Generate ls -la command for file info.

        Uses ls -la instead of stat to avoid shell expansion issues with
        format specifiers.

        Args:
            path: Path to get information about

        Returns:
            The ls command string
        """
        return f"ls -lad {sh_path(path)}"

    def parse_command(self, output: str, path: str) -> FileInfo:
        """Parse ls -la output for a single file/directory.

        BSD ls output format is same as Unix.

        Args:
            output: Raw ls -la command output
            path: Original path requested

        Returns:
            FileInfo object with parsed information
        """
        # BSD ls output format is same as Unix
        unix_cmd = UnixFileInfoCommand()
        return unix_cmd.parse_command(output, path)

create_command

create_command(path: str) -> str

Generate ls -la command for file info.

Uses ls -la instead of stat to avoid shell expansion issues with format specifiers.

Parameters:

Name Type Description Default
path str

Path to get information about

required

Returns:

Type Description
str

The ls command string

Source code in src/anyenv/os_commands/file_info.py
def create_command(self, path: str) -> str:
    """Generate ls -la command for file info.

    Uses ls -la instead of stat to avoid shell expansion issues with
    format specifiers.

    Args:
        path: Path to get information about

    Returns:
        The ls command string
    """
    return f"ls -lad {sh_path(path)}"

parse_command

parse_command(output: str, path: str) -> FileInfo

Parse ls -la output for a single file/directory.

BSD ls output format is same as Unix.

Parameters:

Name Type Description Default
output str

Raw ls -la command output

required
path str

Original path requested

required

Returns:

Type Description
FileInfo

FileInfo object with parsed information

Source code in src/anyenv/os_commands/file_info.py
def parse_command(self, output: str, path: str) -> FileInfo:
    """Parse ls -la output for a single file/directory.

    BSD ls output format is same as Unix.

    Args:
        output: Raw ls -la command output
        path: Original path requested

    Returns:
        FileInfo object with parsed information
    """
    # BSD ls output format is same as Unix
    unix_cmd = UnixFileInfoCommand()
    return unix_cmd.parse_command(output, path)

:fa-brands-github: Show source on GitHub