MCPcopy
hub / github.com/ChinaGodMan/UserScripts / get_file_description

Function get_file_description

utils/content_snippet.py:1–27  ·  view source on GitHub ↗

获取 文件中的相关脚本内容 之间的内容。 参数: file_path: 要检查的文件路径 start_tag: 开始标签 end_tag: 结束标签 返回: 如果找到,返回开始标签和结束标签之间的内容;否则返回 None。

(file_path, start_tag, end_tag)

Source from the content-addressed store, hash-verified

1def get_file_description(file_path, start_tag, end_tag):
2 """
3 获取 文件中的相关脚本内容 之间的内容。
4
5 参数:
6 file_path: 要检查的文件路径
7 start_tag: 开始标签
8 end_tag: 结束标签
9
10 返回:
11 如果找到,返回开始标签和结束标签之间的内容;否则返回 None。
12 """
13 try:
14 with open(file_path, 'r', encoding='utf-8') as f:
15 content = f.read()
16 start_index = content.find(start_tag)
17 end_index = content.find(end_tag, start_index)
18 if start_index == -1 or end_index == -1:
19 return "1"
20 content_between_tags = content[start_index + len(start_tag):end_index].strip()
21 return content_between_tags
22 except FileNotFoundError:
23 print(f"文件未找到: {file_path}")
24 return "1"
25 except Exception as e:
26 print(f"发生错误: {e}")
27 return "1"

Callers 8

mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
process_scriptFunction · 0.90
fix_toc.pyFile · 0.90
format_strFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected