@@ -0,0 +1,1936 @@
+#!/usr/bin/python%0A%0A# This Source Code Form is subject to the terms of the Mozilla Public%0A# License, v. 2.0. If a copy of the MPL was not distributed with this%0A# file, You can obtain one at http://mozilla.org/MPL/2.0/.%0A%0A# nsINode::eText remover.%0A%0Aimport re%0Aimport os%0Aimport argparse%0A%0A%0Adef fileAnalyzer(args, fname):%0A    f = open(fname, %22r%22)%0A    anyFixes = False%0A%0A    if args.fixFiles:%0A        newFile = open(fname + %22.intermediate%22, %22w%22)%0A%0A    for l in f:%0A        l2 = l.replace(%22IsNodeOfType(nsINode::eTEXT)%22, %22IsText()%22)%0A        if l2 == l:%0A            l2 = l.replace(%22IsNodeOfType(eTEXT)%22, %22IsText()%22)%0A        if l2 != l:%0A            print %22found something in file %25s%22 %25 fname%0A            anyFixes = True%0A            if args.fixFiles:%0A                newFile.write(l2)%0A                continue%0A            continue%0A        if args.fixFiles:%0A            newFile.write(l)%0A%0A    f.close()%0A%0A    if args.fixFiles:%0A        newFile.close()%0A        if anyFixes:%0A            os.rename(fname + %22.intermediate%22, fname)%0A        else:%0A            os.remove(fname + %22.intermediate%22)%0A%0A%0Aparser = argparse.ArgumentParser(description='Eliminate uses of nsINode::eTEXT')%0Aparser.add_argument('directory', metavar='D',%0A                    help='Full path of directory to open files from')%0A%0Aparser.add_argument('--fix', dest='fixFiles', action='store_true',%0A                    help='Fix any errors that are found')%0A%0Aargs = parser.parse_args()%0A%0A# To save time, only look at file types that we think will contain C++.%0AfileNamePatt = re.compile(%22%5E.+%5C.(?:cpp%7Ch)$%22)%0A%0Afor (base, _, files) in os.walk(args.directory):%0A    for fileName in files:%0A        if not fileNamePatt.match(fileName):%0A            continue%0A%0A        # XXX Hacky way to not process files in the objdir.%0A        if %22mc/obj-%22 in base:%0A            continue%0A%0A        if not base.endswith(%22/%22):%0A            base += %22/%22%0A        fullFileName = base + fileName%0A%0A        fileAnalyzer(args, fullFileName)%0A

add file for removing uses of eText