19 from . import pep8 |
19 from . import pep8 |
20 |
20 |
21 import Utilities |
21 import Utilities |
22 |
22 |
23 Pep8FixableIssues = ["E101", "E111", "E121", "E122", "E123", "E124", |
23 Pep8FixableIssues = ["E101", "E111", "E121", "E122", "E123", "E124", |
24 "E125", "E126", "E127", "E128", "E133", "W191", "E201", "E202", "E203", |
24 "E125", "E126", "E127", "E128", "E133", "W191", |
25 "E211", "E221", "E222", "E223", "E224", "E225", |
25 "E201", "E202", "E203", "E211", "E221", "E222", |
26 "E226", "E227", "E228", "E231", "E241", "E242", |
26 "E223", "E224", "E225", "E226", "E227", "E228", |
27 "E251", "E261", "E262", "E271", "E272", "E273", |
27 "E231", "E241", "E242", "E251", "E261", "E262", |
28 "E274", "W291", "W292", "W293", "E301", "E302", |
28 "E271", "E272", "E273", "E274", "W291", "W292", |
29 "E303", "E304", "W391", "E401", "E502", "W603", |
29 "W293", "E301", "E302", "E303", "E304", "W391", |
30 "E701", "E702", "E703", "E711", "E712" |
30 "E401", "E502", "W603", "E701", "E702", "E703", |
|
31 "E711", "E712" |
31 ] |
32 ] |
32 |
33 |
33 |
34 |
34 class Pep8Fixer(QObject): |
35 class Pep8Fixer(QObject): |
35 """ |
36 """ |
36 Class implementing a fixer for certain PEP 8 issues. |
37 Class implementing a fixer for certain PEP 8 issues. |
37 """ |
38 """ |
38 def __init__(self, project, filename, sourceLines, fixCodes, inPlace): |
39 def __init__(self, project, filename, sourceLines, fixCodes, noFixCodes, |
|
40 maxLineLength, inPlace): |
39 """ |
41 """ |
40 Constructor |
42 Constructor |
41 |
43 |
42 @param project reference to the project object (Project) |
44 @param project reference to the project object (Project) |
43 @param filename name of the file to be fixed (string) |
45 @param filename name of the file to be fixed (string) |
44 @param sourceLines list of source lines including eol marker |
46 @param sourceLines list of source lines including eol marker |
45 (list of string) |
47 (list of string) |
46 @param fixCodes list of codes to be fixed as a comma separated |
48 @param fixCodes list of codes to be fixed as a comma separated |
47 string (string) |
49 string (string) |
|
50 @param noFixCodes list of codes not to be fixed as a comma |
|
51 separated string (string) |
|
52 @param maxLineLength maximum allowed line length (integer) |
48 @param inPlace flag indicating to modify the file in place (boolean) |
53 @param inPlace flag indicating to modify the file in place (boolean) |
49 """ |
54 """ |
50 super().__init__() |
55 super().__init__() |
51 |
56 |
52 self.__project = project |
57 self.__project = project |
53 self.__filename = filename |
58 self.__filename = filename |
54 self.__origName = "" |
59 self.__origName = "" |
55 self.__source = sourceLines[:] # save a copy |
60 self.__source = sourceLines[:] # save a copy |
56 self.__fixCodes = [c.strip() for c in fixCodes.split(",") if c.strip()] |
61 self.__fixCodes = [c.strip() for c in fixCodes.split(",") if c.strip()] |
|
62 self.__noFixCodes = [c.strip() for c in noFixCodes.split(",") if c.strip()] |
|
63 self.__maxLineLength = maxLineLength |
57 self.fixed = 0 |
64 self.fixed = 0 |
58 |
65 |
59 self.__reindenter = None |
66 self.__reindenter = None |
60 self.__eol = "" |
67 self.__eol = "" |
61 self.__indentWord = self.__getIndentWord() |
68 self.__indentWord = self.__getIndentWord() |