Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc3b6b18

Browse files
committed
fixes#35
1 parentfa346e5 commitc3b6b18

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

‎dialoghelper/_modidx.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
'dialoghelper.core.read_msg': ('core.html#read_msg','dialoghelper/core.py'),
2727
'dialoghelper.core.run_msg': ('core.html#run_msg','dialoghelper/core.py'),
2828
'dialoghelper.core.tool_info': ('core.html#tool_info','dialoghelper/core.py'),
29-
'dialoghelper.core.update_msg': ('core.html#update_msg','dialoghelper/core.py')},
29+
'dialoghelper.core.update_msg': ('core.html#update_msg','dialoghelper/core.py'),
30+
'dialoghelper.core.url2note': ('core.html#url2note','dialoghelper/core.py')},
3031
'dialoghelper.db_dc': {},
3132
'dialoghelper.experimental': {'dialoghelper.experimental._pop_data': ('experimental.html#_pop_data',
3233
'dialoghelper/experimental.py'),

‎dialoghelper/core.py‎

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

33
# %% auto 0
44
__all__= ['Placements','empty','find_var','call_endp','find_dname','find_msg_id','curr_dialog','find_msgs','msg_idx',
5-
'read_msg','add_html','del_msg','run_msg','add_msg','update_msg','load_gist','gist_file',
5+
'read_msg','add_html','del_msg','run_msg','add_msg','update_msg','url2note','load_gist','gist_file',
66
'import_string','is_usable_tool','mk_toollist','import_gist','tool_info','asdict']
77

88
# %% ../nbs/00_core.ipynb
@@ -191,6 +191,16 @@ def update_msg(
191191
ifnotmsgidandnotmsg:raiseTypeError("update_msg needs either a dict message or `msgid=`")
192192
returncall_endp('add_relative_',dname,placement='update',msgid=msgid,**kwargs)
193193

194+
# %% ../nbs/00_core.ipynb
195+
defurl2note(
196+
url:str,# URL to read
197+
extract_section:bool=True,# If url has an anchor, return only that section
198+
selector:str=None# Select section(s) using BeautifulSoup.select (overrides extract_section)
199+
):
200+
"Read URL as markdown, and add a note below current message with the result"
201+
res=read_url(url,as_md=True,extract_section=extract_section,selector=selector)
202+
returnadd_msg(res)
203+
194204
# %% ../nbs/00_core.ipynb
195205
defload_gist(gist_id:str):
196206
"Retrieve a gist"
@@ -270,5 +280,6 @@ def tool_info():
270280
- &`read_msg`: Get the message indexed in the current dialog.
271281
- &`del_msg`: Delete a message from the dialog.
272282
- &`add_msg`: Add/update a message to the queue to show after code execution completes.
273-
- &`update_msg`: Update an existing message.'''
283+
- &`update_msg`: Update an existing message.
284+
- &`url2note`: Read URL as markdown, and add a note below current message with the result'''
274285
add_msg(cts)

‎nbs/00_core.ipynb‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,23 @@
672672
"del_msg(_id)"
673673
]
674674
},
675+
{
676+
"cell_type":"code",
677+
"execution_count":null,
678+
"metadata": {},
679+
"outputs": [],
680+
"source": [
681+
"#| export\n",
682+
"def url2note(\n",
683+
" url:str, # URL to read\n",
684+
" extract_section:bool=True, # If url has an anchor, return only that section\n",
685+
" selector:str=None # Select section(s) using BeautifulSoup.select (overrides extract_section)\n",
686+
"):\n",
687+
"\"Read URL as markdown, and add a note below current message with the result\"\n",
688+
" res = read_url(url, as_md=True, extract_section=extract_section, selector=selector)\n",
689+
" return add_msg(res)"
690+
]
691+
},
675692
{
676693
"cell_type":"markdown",
677694
"metadata": {},
@@ -1020,7 +1037,8 @@
10201037
"- &`read_msg`: Get the message indexed in the current dialog.\n",
10211038
"- &`del_msg`: Delete a message from the dialog.\n",
10221039
"- &`add_msg`: Add/update a message to the queue to show after code execution completes.\n",
1023-
"- &`update_msg`: Update an existing message.'''\n",
1040+
"- &`update_msg`: Update an existing message.\n",
1041+
"- &`url2note`: Read URL as markdown, and add a note below current message with the result'''\n",
10241042
" add_msg(cts)"
10251043
]
10261044
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp