about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/actions.py3
-rw-r--r--ranger/ext/trim.py31
2 files changed, 2 insertions, 32 deletions
diff --git a/ranger/actions.py b/ranger/actions.py
index 25c8262c..bc6da7b8 100644
--- a/ranger/actions.py
+++ b/ranger/actions.py
@@ -1,5 +1,6 @@
 import os
 import shutil
+from inspect import cleandoc
 
 from ranger.shared import EnvironmentAware, SettingsAware
 from ranger import fsobject
@@ -183,7 +184,7 @@ class Actions(EnvironmentAware, SettingsAware):
 			return
 
 		pager = self.ui.open_pager()
-		lines = trimmed_lines_of_docstring(command.__doc__)
+		lines = cleandoc(command.__doc__).split('\n')
 		pager.set_source(lines)
 	
 	def display_log(self):
diff --git a/ranger/ext/trim.py b/ranger/ext/trim.py
deleted file mode 100644
index d469435d..00000000
--- a/ranger/ext/trim.py
+++ /dev/null
@@ -1,31 +0,0 @@
-import sys
-
-def trim_docstring(docstring):
-	if not docstring:
-		return ''
-	return '\n'.join(trimmed_lines_of_docstring(docstring))
-
-def trimmed_lines_of_docstring(docstring):
-	if not docstring:
-		return []
-	# Convert tabs to spaces (following the normal Python rules)
-	# and split into a list of lines:
-	lines = docstring.expandtabs().splitlines()
-	# Determine minimum indentation (first line doesn't count):
-	indent = sys.maxint
-	for line in lines[1:]:
-		stripped = line.lstrip()
-		if stripped:
-			indent = min(indent, len(line) - len(stripped))
-	# Remove indentation (first line is special):
-	trimmed = [lines[0].strip()]
-	if indent < sys.maxint:
-		for line in lines[1:]:
-			trimmed.append(line[indent:].rstrip())
-	# Strip off trailing and leading blank lines:
-	while trimmed and not trimmed[-1]:
-		trimmed.pop()
-	while trimmed and not trimmed[0]:
-		trimmed.pop(0)
-	# Return a single string:
-	return trimmed
href='#n144'>144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257