# Path: formatters/log.py
# class Log:
# 
#     DEBUG = False
# 
#     @staticmethod
#     def d(tag, message):
#         if Log.DEBUG: print "D/%s: %s" %(tag, message)
# 
#     @staticmethod
#     def i(tag, message):
#         print "I/%s: %s" %(tag, message)
# 
#     @staticmethod
#     def w(tag, message):
#         print "W/%s: %s" %(tag, message)
# 
#     @staticmethod
#     def e(tag, message):
#         print "E/%s: %s" %(tag, message)


import os
import commands
import shutil
import fnmatch
import tempfile
from config import Config
from smaliparser.Smali import Smali
from formatters.log import Log
class SmaliSplitter:
    """ Independent splitter of SMALI file
    """

    def split(self, origSmali, output=None):
        """ Split the original SMALI file into partitions
        """

        if output == None: output = os.path.dirname(origSmali)

        self.mOrigSmali = origSmali
        self.mOutput    = output
        self.mPartList  = Smali(origSmali).split(self.mOutput)

        return self

    def match(self, part):
        basename = os.path.basename(part)
        return os.path.join(self.mOutput, basename)

    def getAllParts(self):
        return self.mPartList

    def appendPart(self, part):
        """ Append a part to list if not exist
        """

        try:
            self.mPartList.index(part)
        except:

# Path: formatters/log.py
# class Log:
# 
#     DEBUG = False
# 
#     @staticmethod
#     def d(tag, message):
#         if Log.DEBUG: print "D/%s: %s" %(tag, message)
# 
#     @staticmethod
#     def i(tag, message):
#         print "I/%s: %s" %(tag, message)
# 
#     @staticmethod
#     def w(tag, message):
#         print "W/%s: %s" %(tag, message)
# 
#     @staticmethod
#     def e(tag, message):
#         print "E/%s: %s" %(tag, message)


# Path: autopatch/diff_patch.py
import os
import commands
import shutil
import fnmatch
import tempfile
from config import Config
from smaliparser.Smali import Smali
from formatters.log import Log

class SmaliSplitter:
    """ Independent splitter of SMALI file
    """

    def split(self, origSmali, output=None):
        """ Split the original SMALI file into partitions
        """

        if output == None: output = os.path.dirname(origSmali)

        self.mOrigSmali = origSmali
        self.mOutput    = output
        self.mPartList  = Smali(origSmali).split(self.mOutput)

        return self

    def match(self, part):
        basename = os.path.basename(part)
        return os.path.join(self.mOutput, basename)

    def getAllParts(self):
        return self.mPartList

    def appendPart(self, part):
        """ Append a part to list if not exist
        """

        try:
            self.mPartList.index(part)
        except:

            Log.d(TAG, "  [Add new part %s ] " % part)