# 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)


from command import AndroidFile
from formatters.log import Log
import tempfile
import os
import imagetype
import shutil
import string
import sys
                        blkSize = string.atoi(splitArray[2])
                    except:
                        continue
                    blkName = splitArray[3]
                    adBlk = AndroidFile("%s/%s" %(pull.BLOCK_DIR, blkName))
                    if blkSize >= minsize and blkSize <= maxsize and adBlk.exist():
                        outAdDict[blkName] = adBlk
        Log.i(LOG_TAG, "Create block of partitions done!")
        return outAdDict
    
    def __pull__(self, adDict):
        Log.i(LOG_TAG, "Pull blocks from device ...")
        for blkName in adDict.keys():
            pcOut = os.path.join(self.mWorkdir, blkName)
            if adDict[blkName].pull(pcOut):
                Log.i(LOG_TAG, "...")
                img = imagetype.imagetype(pcOut)
                itype = img.getType()
                if itype is not None:
                    self.mImgDict[itype] = pcOut
                img.exit()
            if len(self.mImgDict.keys()) >= 2: # both boot and rec had found
                return
                
    def out(self, outDir = None):
        if outDir is None:
            outDir = self.mOutDir
        for itype in self.mImgDict.keys():
            outFile = os.path.join(outDir, "%s.img" %(itype))
            shutil.copyfile(self.mImgDict[itype], outFile)

# 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: bootimgpack/pull/pull.py
from command import AndroidFile
from formatters.log import Log
import tempfile
import os
import imagetype
import shutil
import string
import sys

                        blkSize = string.atoi(splitArray[2])
                    except:
                        continue
                    blkName = splitArray[3]
                    adBlk = AndroidFile("%s/%s" %(pull.BLOCK_DIR, blkName))
                    if blkSize >= minsize and blkSize <= maxsize and adBlk.exist():
                        outAdDict[blkName] = adBlk
        Log.i(LOG_TAG, "Create block of partitions done!")
        return outAdDict
    
    def __pull__(self, adDict):
        Log.i(LOG_TAG, "Pull blocks from device ...")
        for blkName in adDict.keys():
            pcOut = os.path.join(self.mWorkdir, blkName)
            if adDict[blkName].pull(pcOut):
                Log.i(LOG_TAG, "...")
                img = imagetype.imagetype(pcOut)
                itype = img.getType()
                if itype is not None:
                    self.mImgDict[itype] = pcOut
                img.exit()
            if len(self.mImgDict.keys()) >= 2: # both boot and rec had found
                return
                
    def out(self, outDir = None):
        if outDir is None:
            outDir = self.mOutDir
        for itype in self.mImgDict.keys():
            outFile = os.path.join(outDir, "%s.img" %(itype))
            shutil.copyfile(self.mImgDict[itype], outFile)

            Log.i(LOG_TAG, "Out: %s" %(outFile))