( filename )
| 195 | ) |
| 196 | |
| 197 | def fixFile( filename ) : |
| 198 | |
| 199 | lines = open( filename ).readlines() |
| 200 | |
| 201 | includes = collections.defaultdict( set ) |
| 202 | defaultVisibility = False |
| 203 | firstInclude, lastInclude = None, None |
| 204 | nonBlankLines = set() |
| 205 | for lineNumber, line in enumerate( lines ) : |
| 206 | |
| 207 | line = line.rstrip() |
| 208 | |
| 209 | if line == "IECORE_PUSH_DEFAULT_VISIBILITY" : |
| 210 | |
| 211 | if defaultVisibility : |
| 212 | warning( filename, lineNumber, "Bad default visibility nesting detected" ) |
| 213 | defaultVisibility = True |
| 214 | |
| 215 | elif line == "IECORE_POP_DEFAULT_VISIBILITY" : |
| 216 | |
| 217 | if not defaultVisibility : |
| 218 | warning( filename, lineNumber, "Bad default visibility nesting detected" ) |
| 219 | defaultVisibility = False |
| 220 | |
| 221 | elif line.startswith( "#include" ) : |
| 222 | |
| 223 | includeFile = line.split()[1].strip( '"' ).lstrip( "<" ).rstrip( ">" ) |
| 224 | |
| 225 | if includeFile in requiresDefaultVisibility : |
| 226 | includes["IECore"].add( "IECore/Export.h" ) |
| 227 | if not defaultVisibility : |
| 228 | info( filename, lineNumber, "Include {0} will have default visibility added".format( includeFile ) ) |
| 229 | else : |
| 230 | if defaultVisibility : |
| 231 | warning( filename, lineNumber, "Include {0} will have default visibility removed".format( includeFile ) ) |
| 232 | |
| 233 | if line.endswith( '.inl"' ) and os.path.splitext( filename )[1] != ".cpp" : |
| 234 | continue |
| 235 | |
| 236 | c = category( includeFile, filename ) |
| 237 | if c == "unknown" : |
| 238 | warning( filename, lineNumber, "Include {0} is uncategorised".format( includeFile ) ) |
| 239 | |
| 240 | if c == "self" and len( includes[c] ) : |
| 241 | warning( filename, lineNumber, "Found multiple self includes - not making any changes" ) |
| 242 | return |
| 243 | |
| 244 | includes[c].add( includeFile ) |
| 245 | |
| 246 | elif line != "" : |
| 247 | |
| 248 | nonBlankLines.add( lineNumber ) |
| 249 | continue |
| 250 | |
| 251 | else : |
| 252 | |
| 253 | continue |
| 254 |
no test coverage detected