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

Method checkFileForTrailingSpaces

tests/test_source_chars.py:35–48  ·  view source on GitHub ↗
(self, filename)

Source from the content-addressed store, hash-verified

33 self.output.write("file %s contains %d tab characters!\n" % (filename, tabCount))
34
35 def checkFileForTrailingSpaces(self, filename):
36 txt = open_and_read(filename, 'r')
37 initSize = len(txt)
38 badLines = 0
39 badChars = 0
40 for line in string.split(txt, '\n'):
41 stripped = string.rstrip(line)
42 spaces = len(line) - len(stripped) # OK, so they might be trailing tabs, who cares?
43 if spaces:
44 badLines = badLines + 1
45 badChars = badChars + spaces
46
47 if badChars <> 0:
48 self.output.write("file %s contains %d trailing spaces, or %0.2f%% wastage\n" % (filename, badChars, 100.0*badChars/initSize))
49
50 def testFiles(self):
51 w = GlobDirectoryWalker(RL_HOME, '*.py')

Callers 1

testFilesMethod · 0.95

Calls 3

open_and_readFunction · 0.90
splitMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected