trading_agent.terminal.attachable_files
¶
Decides which local files can be attached to a message, and finds them in typed or pasted text.
The rules copy the web page's: pictures (PNG, JPEG, WebP, GIF) and documents (PDF, Word, Excel, CSV, TSV, text, Markdown, JSON), up to 20 MB each. A file dragged onto a terminal window arrives as its pasted path, sometimes quoted, with escaped spaces, or as a file:// address, so pasted text is read in all those forms.
Typical usage example:
files = AttachableFiles() files.from_paste("'/home/me/chart one.png'") # [Path('/home/me/chart one.png')] files.problem(Path('notes.exe')) # 'notes.exe is not a picture or document the desk can read'
AttachableFiles
¶
The rules for files that can go with a message.
problem
¶
Says why a file cannot be attached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
The file. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The reason, or None when it can be attached. |
Source code in src/trading_agent/terminal/attachable_files.py
from_paste
¶
Reads pasted text as dropped files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The pasted text. |
required |
Returns:
| Type | Description |
|---|---|
list[Path]
|
The files, when every word of the text is an existing file; otherwise an empty list, so the text is pasted as text. |
Source code in src/trading_agent/terminal/attachable_files.py
mentioned
¶
Finds @path words that name existing files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The message. |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[str, Path]]
|
Each @word as typed and the file it names. |
Source code in src/trading_agent/terminal/attachable_files.py
suggestions
¶
Files and folders that start with a partly typed path, for the @ menu.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
partial
|
str
|
The path typed after @, such as "docs/ch". |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Matching paths as they would be typed, folders ending in "/", attachable files and folders only. |