eric6/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleFixer.py

changeset 8207
d359172d11be
parent 7923
91e843545d9a
child 8217
385f60c94548
equal deleted inserted replaced
8206:adf11836cfce 8207:d359172d11be
36 "N804", "N805", "N806", 36 "N804", "N805", "N806",
37 "W191", "W291", "W292", "W293", "W391", "W603", 37 "W191", "W291", "W292", "W293", "W391", "W603",
38 ] 38 ]
39 39
40 40
41 class CodeStyleFixer(object): 41 class CodeStyleFixer:
42 """ 42 """
43 Class implementing a fixer for certain code style issues. 43 Class implementing a fixer for certain code style issues.
44 """ 44 """
45 def __init__(self, filename, sourceLines, fixCodes, noFixCodes, 45 def __init__(self, filename, sourceLines, fixCodes, noFixCodes,
46 maxLineLength, blankLines, inPlace, eol, backup=False): 46 maxLineLength, blankLines, inPlace, eol, backup=False):
2037 self.__source[line - 1] = self.__source[line - 1].replace("<>", "!=") 2037 self.__source[line - 1] = self.__source[line - 1].replace("<>", "!=")
2038 # '<>' replaced by '!='. 2038 # '<>' replaced by '!='.
2039 return (1, "FIXW603", [], 0) 2039 return (1, "FIXW603", [], 0)
2040 2040
2041 2041
2042 class Reindenter(object): 2042 class Reindenter:
2043 """ 2043 """
2044 Class to reindent badly-indented code to uniformly use four-space 2044 Class to reindent badly-indented code to uniformly use four-space
2045 indentation. 2045 indentation.
2046 2046
2047 Released to the public domain, by Tim Peters, 03 October 2000. 2047 Released to the public domain, by Tim Peters, 03 October 2000.
2235 while i < n and line[i] == " ": 2235 while i < n and line[i] == " ":
2236 i += 1 2236 i += 1
2237 return i 2237 return i
2238 2238
2239 2239
2240 class IndentationWrapper(object): 2240 class IndentationWrapper:
2241 """ 2241 """
2242 Class used by fixers dealing with indentation. 2242 Class used by fixers dealing with indentation.
2243 2243
2244 Each instance operates on a single logical line. 2244 Each instance operates on a single logical line.
2245 """ 2245 """
2462 last_token_multiline = (start[0] != end[0]) 2462 last_token_multiline = (start[0] != end[0])
2463 2463
2464 return valid_indents 2464 return valid_indents
2465 2465
2466 2466
2467 class LineShortener(object): 2467 class LineShortener:
2468 """ 2468 """
2469 Class used to shorten lines to a given maximum of characters. 2469 Class used to shorten lines to a given maximum of characters.
2470 """ 2470 """
2471 def __init__(self, curLine, prevLine, nextLine, maxLength=79, eol="\n", 2471 def __init__(self, curLine, prevLine, nextLine, maxLength=79, eol="\n",
2472 indentWord=" ", isDocString=False): 2472 indentWord=" ", isDocString=False):

eric ide

mercurial