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

Commit50edaf1

Browse files
committed
reorder
1 parent8453f48 commit50edaf1

File tree

2 files changed

+211
-190
lines changed

2 files changed

+211
-190
lines changed

‎dialoghelper/core.py‎

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

33
# %% auto 0
44
__all__= ['dh_settings','Placements','empty','find_var','set_var','call_endp','find_dname','find_msg_id','curr_dialog',
5-
'find_msgs','msg_idx','add_html','add_msg','del_msg','update_msg','url2note','ast_py','ast_grep',
6-
'read_msg','run_msg','msg_insert_line','msg_str_replace','msg_strs_replace','msg_replace_lines',
5+
'msg_idx','find_msgs','add_html','add_msg','del_msg','update_msg','read_msg','run_msg','url2note',
6+
'ast_py','ast_grep','msg_insert_line','msg_str_replace','msg_strs_replace','msg_replace_lines',
77
'load_gist','gist_file','import_string','is_usable_tool','mk_toollist','import_gist','tool_info',
88
'fc_tool_info']
99

@@ -71,6 +71,15 @@ def curr_dialog(
7171
res=call_endp('curr_dialog_',dname,json=True,with_messages=with_messages)
7272
ifres:return {'name':res['name'],'mode':res['mode']}
7373

74+
# %% ../nbs/00_core.ipynb
75+
defmsg_idx(
76+
msgid=None,# Message id to find (defaults to current message)
77+
dname:str=''# Running dialog to get info for; defaults to current dialog
78+
):
79+
"Get absolute index of message in dialog."
80+
ifnotmsgid:msgid=find_msg_id()
81+
returncall_endp('msg_idx_',dname,json=True,msgid=msgid)['msgid']
82+
7483
# %% ../nbs/00_core.ipynb
7584
deffind_msgs(
7685
re_pattern:str='',# Optional regex to search for (re.DOTALL+re.MULTILINE is used)
@@ -85,15 +94,6 @@ def find_msgs(
8594
foroinres:o.pop('output',None)
8695
returnres
8796

88-
# %% ../nbs/00_core.ipynb
89-
defmsg_idx(
90-
msgid=None,# Message id to find (defaults to current message)
91-
dname:str=''# Running dialog to get info for; defaults to current dialog
92-
):
93-
"Get absolute index of message in dialog."
94-
ifnotmsgid:msgid=find_msg_id()
95-
returncall_endp('msg_idx_',dname,json=True,msgid=msgid)['msgid']
96-
9797
# %% ../nbs/00_core.ipynb
9898
defadd_html(
9999
content:str,# The HTML to send to the client (generally should include hx-swap-oob)
@@ -185,6 +185,30 @@ def update_msg(
185185
set_var('__msg_id',res)
186186
returnres
187187

188+
# %% ../nbs/00_core.ipynb
189+
defread_msg(
190+
n:int=-1,# Message index (if relative, +ve is downwards)
191+
relative:bool=True,# Is `n` relative to current message (True) or absolute (False)?
192+
msgid:str=None,# Message id to find (defaults to current message)
193+
view_range:list[int,int]=None,# Optional 1-indexed (start, end) line range for files, end=-1 for EOF
194+
nums:bool=False,# Whether to show line numbers
195+
dname:str=''# Running dialog to get info for; defaults to current dialog
196+
):
197+
"Get the `Message` object indexed in the current dialog."
198+
ifnotmsgid:msgid=find_msg_id()
199+
data=dict(n=n,relative=relative,msgid=msgid)
200+
ifview_range:data['view_range']=view_range# None gets converted to '' so we avoid passing it to use the p.default
201+
ifnums:data['nums']=nums
202+
returncall_endp('read_msg_',dname,json=True,**data)
203+
204+
# %% ../nbs/00_core.ipynb
205+
defrun_msg(
206+
msgid:str=None,# id of message to execute
207+
dname:str=''# Running dialog to get info for; defaults to current dialog
208+
):
209+
"Adds a message to the run queue. Use read_msg to see the output once it runs."
210+
returncall_endp('add_runq_',dname,msgid=msgid,api=True)
211+
188212
# %% ../nbs/00_core.ipynb
189213
defurl2note(
190214
url:str,# URL to read
@@ -214,30 +238,6 @@ def ast_grep(
214238
res=subprocess.run(cmd,shell=True,capture_output=True,text=True)
215239
returnjson.loads(res.stdout)ifres.stdoutelseres.stderr
216240

217-
# %% ../nbs/00_core.ipynb
218-
defread_msg(
219-
n:int=-1,# Message index (if relative, +ve is downwards)
220-
relative:bool=True,# Is `n` relative to current message (True) or absolute (False)?
221-
msgid:str=None,# Message id to find (defaults to current message)
222-
view_range:list[int,int]=None,# Optional 1-indexed (start, end) line range for files, end=-1 for EOF
223-
nums:bool=False,# Whether to show line numbers
224-
dname:str=''# Running dialog to get info for; defaults to current dialog
225-
):
226-
"Get the `Message` object indexed in the current dialog."
227-
ifnotmsgid:msgid=find_msg_id()
228-
data=dict(n=n,relative=relative,msgid=msgid)
229-
ifview_range:data['view_range']=view_range# None gets converted to '' so we avoid passing it to use the p.default
230-
ifnums:data['nums']=nums
231-
returncall_endp('read_msg_',dname,json=True,**data)
232-
233-
# %% ../nbs/00_core.ipynb
234-
defrun_msg(
235-
msgid:str=None,# id of message to execute
236-
dname:str=''# Running dialog to get info for; defaults to current dialog
237-
):
238-
"Adds a message to the run queue. Use read_msg to see the output once it runs."
239-
returncall_endp('add_runq_',dname,msgid=msgid,api=True)
240-
241241
# %% ../nbs/00_core.ipynb
242242
defmsg_insert_line(
243243
msgid:str,# Message id to edit

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp