Skip to content

Commit ea7e1cb

Browse files
committed
export
1 parent e0bf39a commit ea7e1cb

File tree

2 files changed

+29
-32
lines changed

2 files changed

+29
-32
lines changed

fastcore/tools.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/12_tools.ipynb.
44

5-
# %% auto 0
5+
# %% auto #0
66
__all__ = ['explain_exc', 'ensure', 'valid_path', 'run_cmd', 'rg', 'sed', 'view', 'create', 'insert', 'str_replace',
77
'strs_replace', 'replace_lines', 'move_lines', 'get_callable']
88

@@ -12,7 +12,7 @@
1212
from shlex import split
1313
from subprocess import run, DEVNULL
1414

15-
# %% ../nbs/12_tools.ipynb
15+
# %% ../nbs/12_tools.ipynb #7603dedb
1616
def explain_exc(task=''):
1717
"""Convert an current exception to an LLM friendly error message."""
1818
try: raise sys.exc_info()[1]
@@ -21,20 +21,20 @@ def explain_exc(task=''):
2121
except Exception as e: return f"Error {task}: {repr(e)}"
2222

2323

24-
# %% ../nbs/12_tools.ipynb
24+
# %% ../nbs/12_tools.ipynb #b8823d07
2525
def ensure(b: bool, msg:str=""):
2626
"Works like assert b, msg but raise ValueError and is not disabled when run with python -O"
2727
if not b: raise ValueError(msg)
2828

2929

30-
# %% ../nbs/12_tools.ipynb
30+
# %% ../nbs/12_tools.ipynb #e4288129
3131
def valid_path(path:str, must_exist:bool=True) -> Path:
3232
'Return expanded/resolved Path, raising FileNotFoundError if must_exist and missing'
3333
p = Path(path).expanduser().resolve()
3434
if must_exist and not p.exists(): raise FileNotFoundError(f'File not found: {p}')
3535
return p
3636

37-
# %% ../nbs/12_tools.ipynb
37+
# %% ../nbs/12_tools.ipynb #1182336d
3838
def run_cmd(
3939
cmd:str, # The command name to run
4040
argstr:str='', # All args to the command, will be split with shlex
@@ -69,8 +69,8 @@ def sed(
6969
"Run the `sed` command with the args in `argstr` (e.g for reading a section of a file)"
7070
return run_cmd('sed', argstr, allow_re=allow_re, disallow_re=disallow_re)
7171

72-
# %% ../nbs/12_tools.ipynb
73-
def _fmt_path(f, p):
72+
# %% ../nbs/12_tools.ipynb #864b213a
73+
def _fmt_path(f, p, skip_folders=()):
7474
'Format path with emoji for dirs/symlinks or size for files'
7575
parts = f.relative_to(p).parts
7676
if any(part.startswith('.') for part in parts): return None
@@ -79,7 +79,7 @@ def _fmt_path(f, p):
7979
if f.is_dir(): return f'{f} 📁'
8080
return f'{f} ({f.stat().st_size/1024:.1f}k)'
8181

82-
# %% ../nbs/12_tools.ipynb #f2e2f69c
82+
# %% ../nbs/12_tools.ipynb #5dd1aaf3
8383
def view(
8484
path:str, # Path to directory or file to view
8585
view_range:tuple[int,int]=None, # Optional 1-indexed (start, end) line range for files, end=-1 for EOF. Do NOT use unless it's known that the file is too big to keep in context—simply view the WHOLE file when possible

nbs/12_tools.ipynb

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
{
160160
"data": {
161161
"text/plain": [
162-
"Path('/app/data/repos/fastcore/nbs')"
162+
"Path('/Users/jhoward/aai-ws/fastcore/nbs')"
163163
]
164164
},
165165
"execution_count": null,
@@ -181,7 +181,7 @@
181181
"name": "stdout",
182182
"output_type": "stream",
183183
"text": [
184-
"Error: File not found: /app/data/repos/fastcore/nbs/.missing\n"
184+
"Error: File not found: /Users/jhoward/aai-ws/fastcore/nbs/.missing\n"
185185
]
186186
}
187187
],
@@ -241,14 +241,14 @@
241241
"name": "stdout",
242242
"output_type": "stream",
243243
"text": [
244-
"000_tour.ipynb\n",
244+
"\u001b[34m__pycache__\u001b[m\u001b[m\n",
245+
"_parallel_win.ipynb\n",
246+
"_quarto.yml\n",
245247
"00_test.ipynb\n",
248+
"000_tour.ipynb\n",
246249
"01_basics.ipynb\n",
247250
"02_foundation.ipynb\n",
248-
"03_xtras.ipynb\n",
249-
"03a_parallel.ipynb\n",
250-
"03b_net.ipynb\n",
251-
"04_docments.ipy\n"
251+
"03_xtras\n"
252252
]
253253
}
254254
],
@@ -274,7 +274,7 @@
274274
"name": "stdout",
275275
"output_type": "stream",
276276
"text": [
277-
"ls: cannot access 'f*': No such file or directory\n",
277+
"ls: f*: No such file or directory\n",
278278
"\n"
279279
]
280280
}
@@ -619,11 +619,11 @@
619619
"output_type": "stream",
620620
"text": [
621621
"Directory contents of /path:\n",
622-
"/path/000_tour.ipynb\n",
623-
"/path/00_test.ipynb\n",
624-
"/path/02_foundation.ipynb\n",
625-
"/path/03_xtras.ipynb\n",
626-
"/path/03a_parallel.ipynb\n"
622+
"/path/llms.txt (3.7k)\n",
623+
"/path/000_tour.ipynb (18.2k)\n",
624+
"/path/parallel_test.py (0.6k)\n",
625+
"/path/_quarto.yml (0.8k)\n",
626+
"/path/08_style.ipynb (12.3k)\n"
627627
]
628628
}
629629
],
@@ -759,7 +759,7 @@
759759
"name": "stdout",
760760
"output_type": "stream",
761761
"text": [
762-
"Replaced text in /app/data/repos/fastcore/nbs/test.txt\n",
762+
"Replaced text in /Users/jhoward/aai-ws/fastcore/nbs/test.txt\n",
763763
" 1 │ Let's add a new line:\n",
764764
" 2 │ Hello, world!\n"
765765
]
@@ -820,7 +820,7 @@
820820
"output_type": "stream",
821821
"text": [
822822
"Results for each replacement:\n",
823-
"Replaced text in /app/data/repos/fastcore/nbs/test.txt; Replaced text in /app/data/repos/fastcore/nbs/test.txt\n",
823+
"Replaced text in /Users/jhoward/aai-ws/fastcore/nbs/test.txt; Replaced text in /Users/jhoward/aai-ws/fastcore/nbs/test.txt\n",
824824
" 1 │ Let's just say:\n",
825825
" 2 │ Hello, friends!\n",
826826
" 3 │ Nice to see you.\n"
@@ -1004,13 +1004,7 @@
10041004
"name": "stdout",
10051005
"output_type": "stream",
10061006
"text": [
1007-
"Moved lines 4-5 to line 2\n"
1008-
]
1009-
},
1010-
{
1011-
"name": "stdout",
1012-
"output_type": "stream",
1013-
"text": [
1007+
"Moved lines 4-5 to line 2\n",
10141008
" 1 │ Line 1\n",
10151009
" 2 │ Line 4\n",
10161010
" 3 │ Line 5\n",
@@ -1135,7 +1129,7 @@
11351129
{
11361130
"data": {
11371131
"text/plain": [
1138-
"'run_cmd; rg; sed; view; create; insert; str_replace; strs_replace; replace_lines; move_lines; get_callable; explain_exc; calc_div; ensure; valid_path'"
1132+
"'run_cmd; explain_exc; ensure; valid_path; rg; sed; view; create; insert; str_replace; strs_replace; replace_lines; move_lines; get_callable; calc_div'"
11391133
]
11401134
},
11411135
"execution_count": null,
@@ -1181,7 +1175,10 @@
11811175
]
11821176
}
11831177
],
1184-
"metadata": {},
1178+
"metadata": {
1179+
"solveit_dialog_mode": "learning",
1180+
"solveit_ver": 2
1181+
},
11851182
"nbformat": 4,
11861183
"nbformat_minor": 5
11871184
}

0 commit comments

Comments
 (0)