MCPcopy Create free account
hub / github.com/comaps/comaps / check_raw

Function check_raw

tools/python/check_store_metadata.py:125–142  ·  view source on GitHub ↗
(path, max_length, ignoreEmptyFilesAndNewLines=False)

Source from the content-addressed store, hash-verified

123 return ok
124
125def check_raw(path, max_length, ignoreEmptyFilesAndNewLines=False):
126 ok = True
127 with open(path, 'r') as f:
128 text = f.read()
129 if not ignoreEmptyFilesAndNewLines:
130 if not text:
131 ok = error(path, "empty")
132 elif text[-1] == os.linesep:
133 text = text[:-1]
134 else:
135 ok = error(path, "missing new line")
136 else:
137 text = text.strip()
138
139 cur_length = len(text)
140 if cur_length > max_length:
141 ok = error(path, f'too long {cur_length} (max {max_length})')
142 return ok, text
143
144def check_text(path, max, optional=False, ignoreEmptyFilesAndNewLines=False):
145 try:

Callers 4

check_textFunction · 0.85
check_urlFunction · 0.85
check_emailFunction · 0.85
check_exactFunction · 0.85

Calls 2

errorFunction · 0.85
readMethod · 0.45

Tested by

no test coverage detected