tests/test_source_chars.py
branchpy33
changeset 3721 0c93dd8ff567
parent 3617 ae5744e97c42
child 3794 398ea04239b5
equal deleted inserted replaced
3720:7a059dde5bf5 3721:0c93dd8ff567
    55 
    55 
    56 def zapTrailingWhitespace(dirname):
    56 def zapTrailingWhitespace(dirname):
    57     """Eliminates trailing spaces IN PLACE.  Use with extreme care
    57     """Eliminates trailing spaces IN PLACE.  Use with extreme care
    58     and only after a backup or with version-controlled code."""
    58     and only after a backup or with version-controlled code."""
    59     assert os.path.isdir(dirname), "Directory not found!"
    59     assert os.path.isdir(dirname), "Directory not found!"
    60     print "This will eliminate all trailing spaces in py files under %s." % dirname
    60     print("This will eliminate all trailing spaces in py files under %s." % dirname)
    61     ok = raw_input("Shall I proceed?  type YES > ")
    61     ok = input("Shall I proceed?  type YES > ")
    62     if ok != 'YES':
    62     if ok != 'YES':
    63         print 'aborted by user'
    63         print('aborted by user')
    64         return
    64         return
    65     w = GlobDirectoryWalker(dirname, '*.py')
    65     w = GlobDirectoryWalker(dirname, '*.py')
    66     for filename in w:
    66     for filename in w:
    67         # trim off final newline and detect real changes
    67         # trim off final newline and detect real changes
    68         txt = open(filename, 'r').read()
    68         txt = open(filename, 'r').read()
    75             if spaces:
    75             if spaces:
    76                 badChars = badChars + spaces
    76                 badChars = badChars + spaces
    77 
    77 
    78         if badChars != 0:
    78         if badChars != 0:
    79             open(filename, 'w').write(string.join(cleaned, '\n'))
    79             open(filename, 'w').write(string.join(cleaned, '\n'))
    80             print "file %s contained %d trailing spaces, FIXED" % (filename, badChars)
    80             print("file %s contained %d trailing spaces, FIXED" % (filename, badChars))
    81     print 'done'
    81     print('done')
    82 
    82 
    83 def makeSuite():
    83 def makeSuite():
    84     return makeSuiteForClasses(SourceTester)
    84     return makeSuiteForClasses(SourceTester)
    85 
    85 
    86 
    86