nbinlineai.fastcore_tools
Paths refer to the kernel filesystem and its working directory. Reading a saved notebook file does not reveal unsaved cells in JupyterLab’s live document model.
path_info
path_info(path: str = '.') -> strShow the kernel working directory and a path’s resolved type and size.
| Parameter | Type | Default | Description |
|---|---|---|---|
path |
str | '.' |
Path to inspect from the kernel working directory. |
| returns | str | Bounded working-directory and path report. |
list_files
list_files(path: str = '.', pattern: str = '*', recursive: bool = False, limit: int = 30) -> strList visible paths under a directory, optionally matching entry names.
The scan skips hidden entries, common generated folders, and symlinks. A recursive scan descends at most six levels and visits at most 2,000 entries. The result says when a limit leaves paths unlisted.
| Parameter | Type | Default | Description |
|---|---|---|---|
path |
str | '.' |
Directory to list from the kernel working directory. |
pattern |
str | '*' |
Glob pattern matched against each entry name. |
recursive |
bool | False |
Whether to descend into visible subdirectories. |
limit |
int | 30 |
Maximum matching paths to show, at most 100. |
| returns | str | Bounded visible-path listing, with a partial notice when needed. |
view_file
view_file(path: str, start_line: int = 1, end_line: int = 40) -> strRead a bounded range of one UTF-8 text file with one-based line numbers.
| Parameter | Type | Default | Description |
|---|---|---|---|
path |
str | required | UTF-8 text file to read, at most 1 MB. |
start_line |
int | 1 |
First one-based line to show. |
end_line |
int | 40 |
Last inclusive line to show, at most 80 lines total. |
| returns | str | Bounded text excerpt with one-based line numbers. |
create_file
create_file(path: str, contents: str) -> strCreate a new UTF-8 text file without replacing an existing path.
The tool creates parent directories when needed. The path may be anywhere the kernel can write, except a notebook file. Exclusive creation prevents the tool from replacing an existing file.
| Parameter | Type | Default | Description |
|---|---|---|---|
path |
str | required | New text file path; existing paths and notebook files are refused. |
contents |
str | required | UTF-8 text of at most 8,000 characters. |
| returns | str | Bounded new-file receipt. |
file_str_replace
file_str_replace(path: str, old_str: str, new_str: str, expected_matches: int = 1) -> strReplace a literal only when its occurrence count matches expectation.
The edit checks a regular UTF-8 file of at most 1 MB. It checks the file again before an atomic replacement and returns a bounded diff.
| Parameter | Type | Default | Description |
|---|---|---|---|
path |
str | required | Existing text file path, excluding notebook files. |
old_str |
str | required | Nonempty literal text to replace. |
new_str |
str | required | Replacement text, at most 8,000 characters. |
expected_matches |
int | 1 |
Required occurrence count, at most 100. |
| returns | str | Bounded edit result and diff. |
file_insert_line
file_insert_line(path: str, line: int, new_str: str) -> strInsert text after a one-based line. Zero inserts before the first line.
Supplied text is inserted verbatim. Added boundary separators use the file’s line ending style. Size, change-detection and atomic replacement checks match the other file edits.
| Parameter | Type | Default | Description |
|---|---|---|---|
path |
str | required | Existing text file path, excluding notebook files. |
line |
int | required | One-based line after which to insert, or zero for the start. |
new_str |
str | required | Nonempty text to insert, at most 8,000 characters. |
| returns | str | Bounded edit result and diff. |
file_replace_lines
file_replace_lines(path: str, start_line: int, end_line: int, new_content: str) -> strReplace an inclusive, one-based line range with UTF-8 text.
The edit keeps the file’s line ending style and uses the same size, change-detection, and atomic replacement checks as other file edits.
| Parameter | Type | Default | Description |
|---|---|---|---|
path |
str | required | Existing text file path, excluding notebook files. |
start_line |
int | required | First one-based line to replace. |
end_line |
int | required | Last inclusive line to replace. |
new_content |
str | required | Replacement UTF-8 text, at most 8,000 characters. |
| returns | str | Bounded edit result and diff. |
show_doc
show_doc(name: str, module: str = '') -> strShow docs for a live name, or import module and inspect its public name.
An explicit module import runs that module’s initialization. Use name=“” with module to show the module’s own docs. Static attribute lookup does not call the named symbol. Without a module, name resolves from the live kernel.
| Parameter | Type | Default | Description |
|---|---|---|---|
name |
str | required | Live public name, or public name within module; empty selects the module. |
module |
str | '' |
Installed module to import explicitly; import runs its initialization. |
| returns | str | Bounded Markdown text with rich notebook display. |