MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / CleansedLines

Class CleansedLines

rtpose_wrapper/scripts/cpp_lint.py:1183–1227  ·  view source on GitHub ↗

Holds 3 copies of all lines with different preprocessing applied to them. 1) elided member contains lines without strings and comments, 2) lines member contains lines without comments, and 3) raw_lines member contains all the lines without processing. All these three members are of <type 'l

Source from the content-addressed store, hash-verified

1181
1182
1183class CleansedLines(object):
1184 """Holds 3 copies of all lines with different preprocessing applied to them.
1185
1186 1) elided member contains lines without strings and comments,
1187 2) lines member contains lines without comments, and
1188 3) raw_lines member contains all the lines without processing.
1189 All these three members are of <type 'list'>, and of the same length.
1190 """
1191
1192 def __init__(self, lines):
1193 self.elided = []
1194 self.lines = []
1195 self.raw_lines = lines
1196 self.num_lines = len(lines)
1197 self.lines_without_raw_strings = CleanseRawStrings(lines)
1198 for linenum in range(len(self.lines_without_raw_strings)):
1199 self.lines.append(CleanseComments(
1200 self.lines_without_raw_strings[linenum]))
1201 elided = self._CollapseStrings(self.lines_without_raw_strings[linenum])
1202 self.elided.append(CleanseComments(elided))
1203
1204 def NumLines(self):
1205 """Returns the number of lines represented."""
1206 return self.num_lines
1207
1208 @staticmethod
1209 def _CollapseStrings(elided):
1210 """Collapses strings and chars on a line to simple "" or '' blocks.
1211
1212 We nix strings first so we're not fooled by text like '"http://"&#x27;
1213
1214 Args:
1215 elided: The line being processed.
1216
1217 Returns:
1218 The line with collapsed strings.
1219 """
1220 if not _RE_PATTERN_INCLUDE.match(elided):
1221 # Remove escaped characters first to make quote/single quote collapsing
1222 # basic. Things that look like escaped characters shouldn't occur
1223 # outside of strings and chars.
1224 elided = _RE_PATTERN_CLEANSE_LINE_ESCAPES.sub('', elided)
1225 elided = _RE_PATTERN_CLEANSE_LINE_SINGLE_QUOTES.sub("''", elided)
1226 elided = _RE_PATTERN_CLEANSE_LINE_DOUBLE_QUOTES.sub('""', elided)
1227 return elided
1228
1229
1230def FindEndOfExpressionInLine(line, startpos, depth, startchar, endchar):

Callers 1

ProcessFileDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected