Plugins/CheckerPlugins/Pep8/Pep8Fixer.py

changeset 2912
9ff696796092
parent 2895
4a44d92757f9
child 2921
9e8431cbd2cf
equal deleted inserted replaced
2910:cdc56e9d9f12 2912:9ff696796092
2 2
3 # Copyright (c) 2011 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> 3 # Copyright (c) 2011 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
4 # 4 #
5 5
6 """ 6 """
7 Module implementing a class to fix certain PEP 8 issues. 7 Module implementing a class to fix certain code style issues.
8 """ 8 """
9 9
10 import os 10 import os
11 import re 11 import re
12 import tokenize 12 import tokenize
33 ] 33 ]
34 34
35 35
36 class Pep8Fixer(QObject): 36 class Pep8Fixer(QObject):
37 """ 37 """
38 Class implementing a fixer for certain PEP 8 issues. 38 Class implementing a fixer for certain code style issues.
39 """ 39 """
40 def __init__(self, project, filename, sourceLines, fixCodes, noFixCodes, 40 def __init__(self, project, filename, sourceLines, fixCodes, noFixCodes,
41 maxLineLength, inPlace): 41 maxLineLength, inPlace):
42 """ 42 """
43 Constructor 43 Constructor
158 try: 158 try:
159 Utilities.writeEncodedFile(self.__filename, txt, encoding) 159 Utilities.writeEncodedFile(self.__filename, txt, encoding)
160 except (IOError, Utilities.CodingError, UnicodeError) as err: 160 except (IOError, Utilities.CodingError, UnicodeError) as err:
161 E5MessageBox.critical( 161 E5MessageBox.critical(
162 self, 162 self,
163 self.trUtf8("Fix PEP 8 issues"), 163 self.trUtf8("Fix Code Style Issues"),
164 self.trUtf8( 164 self.trUtf8(
165 """<p>Could not save the file <b>{0}</b>.""" 165 """<p>Could not save the file <b>{0}</b>."""
166 """ Skipping it.</p><p>Reason: {1}</p>""") 166 """ Skipping it.</p><p>Reason: {1}</p>""")
167 .format(self.__filename, str(err)) 167 .format(self.__filename, str(err))
168 ) 168 )

eric ide

mercurial