예제 #1
0
 def __format(self, root, sPath):
     sPath = os.path.abspath(sPath)
     if not FormatSmaliLib.mFormatList.has_key(sPath):
         sFormat = Format(root, sPath)
         sFormat.do(Format.ACCESS_TO_NAME | Format.RESID_TO_NAME
                    | Format.REMOVE_LINE)
         FormatSmaliLib.mFormatList[sPath] = sFormat
         return True
     return False
예제 #2
0
파일: autopatch.py 프로젝트: dibowei/tools
    def singleReplaceOrAdd(target, source):
        """ Add a file from source to target.
            Replace the target if exist.
        """

        # Find out the actual target
        target = ReviseExecutor.TARGET_FINDER.find(target)

        if os.path.exists(target):
            execute = "REPLACE  " + target
        else:
            execute = "    ADD  " + target
            ReviseExecutor.createIfNotExist(os.path.dirname(target))

        if not os.path.exists(source):
            Error.fileNotFound(source)

            return "%s %s" % (Paint.red("  [FAIL]"), execute)

        # Only format access method and res id
        action = Format.ACCESS_TO_NAME | Format.RESID_TO_NAME
        formatSource = Format(AutoPatch.NEWER_ROOT, source).do(action)
        formatTarget = Format(AutoPatch.TARGET_ROOT, target).do(action)

        shutil.copy(source, target)

        # Would not change res name back
        action = Format.ACCESS_TO_NAME
        formatSource.undo(action)
        formatTarget.undo(action)

        return "%s %s" % (Paint.green("  [PASS]"), execute)
예제 #3
0
파일: autopatch.py 프로젝트: dibowei/tools
    def singleMerge(target, older, newer):
        """ Incorporate changes from older to newer into target
        """

        # Find out the actual target loosely
        target = ReviseExecutor.TARGET_FINDER.find(target, loosely=True)

        execute = "  MERGE  " + target

        if not os.path.exists(target) :
            Error.fileNotFound(target)
            return "%s %s" % (Paint.red("  [FAIL]"), execute)

        action = Format.REMOVE_LINE | Format.ACCESS_TO_NAME | Format.RESID_TO_NAME
        formatTarget = Format(AutoPatch.TARGET_ROOT, target).do(action)
        formatOlder  = Format(AutoPatch.OLDER_ROOT,  older).do(action)
        formatNewer  = Format(AutoPatch.NEWER_ROOT,  newer).do(action)

        DiffPatch(target, older, newer).run()

        # Would not change res name back
        action = Format.REMOVE_LINE | Format.ACCESS_TO_NAME
        formatTarget.undo(action)
        formatOlder.undo(action)
        formatNewer.undo(action)

        conflictNum = Rejector(target).getConflictNum()

        if conflictNum > 0 :
            Error.conflict(conflictNum, target)
            return "%s %s" % (Paint.yellow("  [CFLT]"), execute)
        else:
            return "%s %s" % (Paint.green("  [PASS]"), execute)