MacOSFindCommand
Base classes¶
| Name | Children | Inherits |
|---|---|---|
| FindCommand anyenv.os_commands.base Base class for recursive find commands. |
â‹” Inheritance diagram¶
graph TD
967599260["find.MacOSFindCommand"]
1345197150["base.FindCommand"]
925645236["abc.ABC"]
2751680898["builtins.object"]
1345197150 --> 967599260
925645236 --> 1345197150
2751680898 --> 925645236
🛈 DocStrings¶
Bases: FindCommand
macOS find command implementation (BSD find).
Source code in src/anyenv/os_commands/find.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
create_command
¶
create_command(
path: str,
pattern: str | None = None,
maxdepth: int | None = None,
file_type: Literal["file", "directory", "all"] = "all",
with_stats: bool = True,
) -> str
Generate macOS find command.
BSD find doesn't support -printf, so we use -exec stat for file stats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Directory to search in |
required |
pattern
|
str | None
|
Glob pattern for name matching (e.g., "*.py") |
None
|
maxdepth
|
int | None
|
Maximum directory depth to descend |
None
|
file_type
|
Literal['file', 'directory', 'all']
|
Filter by type - files only, directories only, or all |
'all'
|
with_stats
|
bool
|
Include file stats (uses -exec stat, slower than GNU -printf) |
True
|
Returns:
| Type | Description |
|---|---|
str
|
The find command string |
Source code in src/anyenv/os_commands/find.py
parse_command
¶
parse_command(output: str, base_path: str = '') -> list[DirectoryEntry]
Parse macOS find output.
Handles both plain path output and stat-formatted output with stats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
str
|
Raw find command output |
required |
base_path
|
str
|
Base path used in the find command |
''
|
Returns:
| Type | Description |
|---|---|
list[DirectoryEntry]
|
List of DirectoryEntry objects |
Source code in src/anyenv/os_commands/find.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |