MCPcopy
hub / github.com/vladmandic/sdnext / read

Method read

cli/search-docs.py:24–38  ·  view source on GitHub ↗
(self, full: bool = True)

Source from the content-addressed store, hash-verified

22 self.read(full=full)
23
24 def read(self, full: bool = True):
25 try:
26 self.title = ' ' + os.path.basename(self.fn).replace('.md', '').replace('-', ' ') + ' '
27 self.mtime = int(os.path.getmtime(self.fn))
28 with open(self.fn, 'r', encoding='utf-8') as f:
29 content = f.read()
30 self.size = len(content)
31 self.lines = [line.strip().lower() + ' ' for line in content.splitlines() if len(line)>1]
32 self.h1 = [line[1:] for line in self.lines if line.startswith('# ')]
33 self.h2 = [line[2:] for line in self.lines if line.startswith('## ')]
34 self.h3 = [line[3:] for line in self.lines if line.startswith('### ')]
35 if not full:
36 self.lines.clear()
37 except Exception as e:
38 log.error(f'Wiki: page="{self.fn}" {e}')
39
40 def search(self, text):
41 if not text or len(text) < 2:

Callers 11

__init__Method · 0.95
infoFunction · 0.45
count_safetensors_paramsFunction · 0.45
infoFunction · 0.45
infoFunction · 0.45
getMethod · 0.45
infoFunction · 0.45
read_metadataFunction · 0.45
gridFunction · 0.45
download_urllibFunction · 0.45
download_urllib3Function · 0.45

Calls 1

clearMethod · 0.45

Tested by

no test coverage detected