MCPcopy Create free account
hub / github.com/Distrotech/reportlab / dedent

Function dedent

tools/docco/codegrab.py:163–184  ·  view source on GitHub ↗

Attempts to dedent the lines to the edge. Looks at no. of leading spaces in line 2, and removes up to that number of blanks from other lines.

(comment)

Source from the content-addressed store, hash-verified

161
162
163def dedent(comment):
164 """Attempts to dedent the lines to the edge. Looks at no.
165 of leading spaces in line 2, and removes up to that number
166 of blanks from other lines."""
167 commentLines = string.split(comment, '\n')
168 if len(commentLines) < 2:
169 cleaned = map(string.lstrip, commentLines)
170 else:
171 spc = 0
172 for char in commentLines[1]:
173 if char in string.whitespace:
174 spc = spc + 1
175 else:
176 break
177 #now check other lines
178 cleaned = []
179 for line in commentLines:
180 for i in range(min(len(line),spc)):
181 if line[0] in string.whitespace:
182 line = line[1:]
183 cleaned.append(line)
184 return string.join(cleaned, '\n')
185
186
187

Callers 1

getObjectsDefinedInFunction · 0.85

Calls 2

appendMethod · 0.80
splitMethod · 0.45

Tested by

no test coverage detected