MCPcopy Create free account
hub / github.com/numpy/numpy / cleanComments

Function cleanComments

numpy/linalg/lapack_lite/clapack_scrub.py:155–205  ·  view source on GitHub ↗
(source)

Source from the content-addressed store, hash-verified

153
154# This really seems to be about 4x longer than it needs to be
155def cleanComments(source):
156 lines = LineQueue()
157 comments = CommentQueue()
158
159 def isCommentLine(line):
160 return line.startswith('/*') and line.endswith('*/\n')
161
162 blanks = LineQueue()
163
164 def isBlank(line):
165 return line.strip() == ''
166
167 def SourceLines(line):
168 if isCommentLine(line):
169 comments.add(line)
170 return HaveCommentLines
171 else:
172 lines.add(line)
173 return SourceLines
174
175 def HaveCommentLines(line):
176 if isBlank(line):
177 blanks.add('\n')
178 return HaveBlankLines
179 elif isCommentLine(line):
180 comments.add(line)
181 return HaveCommentLines
182 else:
183 comments.flushTo(lines)
184 lines.add(line)
185 return SourceLines
186
187 def HaveBlankLines(line):
188 if isBlank(line):
189 blanks.add('\n')
190 return HaveBlankLines
191 elif isCommentLine(line):
192 blanks.flushTo(comments)
193 comments.add(line)
194 return HaveCommentLines
195 else:
196 comments.flushTo(lines)
197 blanks.flushTo(lines)
198 lines.add(line)
199 return SourceLines
200
201 state = SourceLines
202 for line in UStringIO(source):
203 state = state(line)
204 comments.flushTo(lines)
205 return lines.getValue()
206
207def removeHeader(source):
208 lines = LineQueue()

Callers

nothing calls this directly

Calls 4

flushToMethod · 0.95
getValueMethod · 0.95
LineQueueClass · 0.85
CommentQueueClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…