def trim(self,docstring):
8 if not docstring:
9 return ''
10 lines = docstring.expandtabs().splitlines()
11
12 indent = sys.maxint
13 for line in lines[1:]:
14 stripped = line.lstrip()
15 print stripped
16 if stripped:
17 indent = min(indent, len(line) - len(stripped))
18
19 trimmed = [lines[0].strip()]
20 if indent < sys.maxint:
21 for line in lines[1:]:
22 trimmed.append(line[indent:].rstrip())
23
24 while trimmed and not trimmed[-1]:
25 trimmed.pop()
26 while trimmed and not trimmed[0]:
27 trimmed.pop(0)
28
29 return '\n'.join(trimmed)
宝慕林4294392
慕莱坞森
相关分类