airmtp.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:airmtp 作者: shezi 项目源码 文件源码
def printMtpObjectDirectoryListing():   

    applog_i("") # newline separator for logging

    fUsingRenameEngine = g.args['filenamespec'] != None or g.args['dirnamespec'] != None
    if fUsingRenameEngine:
        renameDict = genRenameDictKeysCommonToAllMtpObjects()

    #
    # scan all objects and generate listing for each file that passes the user-configured filters
    #
    totalBytesOfImagesInObjectsListed = 0
    countFilesListed = 0
    mtpObject = getNextUserFilteredMtpFileObject(-1)
    while mtpObject:

        if fUsingRenameEngine:      
            # update dict with fields that change for each file. note we're using session download count as lifetime for the preview of the renaming
            updateRenameDictKeysSpecificToMtpObject(renameDict, mtpObject, countFilesListed, countFilesListed)
            (dirAfterRename, filenameAfterRename) = performDirAndFileRename(renameDict, False)
            dirAndFilenameAfterRename = os.path.join(dirAfterRename, filenameAfterRename)

        #
        # print information about this file
        #
        timeStr = strutil.getDateTimeStr(mtpObject.captureDateEpoch, fMilitaryTime=False)
        sizeStr = "{:13,}".format(mtpObject.mtpObjectInfo.objectCompressedSize)
        fullPathStr = mtpObject.genFullPathStr()
        if g.countCardsUsed > 1:
            # prepend slot number of file to path string
            fullPathStr = "CARD{:d}\\".format(getSlotIndexFromStorageId(mtpObject.mtpObjectInfo.storageId)) + fullPathStr       
        if not fUsingRenameEngine:
            applog_i("{:s}  {:s} {:s}".format(timeStr, sizeStr, fullPathStr))
        else:
            applog_i("{:s}  {:s} {:s} -> {:s}".format(timeStr, sizeStr, fullPathStr, dirAndFilenameAfterRename))
        totalBytesOfImagesInObjectsListed += mtpObject.mtpObjectInfo.objectCompressedSize
        countFilesListed += 1
        # get next file that passes user-configured filters
        mtpObject = getNextUserFilteredMtpFileObject(mtpObject)

    #
    # print listing summary
    #       
    applog_i("        {:4d} File(s)  {:13,} bytes".format(countFilesListed, totalBytesOfImagesInObjectsListed))
    applog_i("        {:4d} Dir(s)  {:13,} bytes free {:s}".format(MtpObject._CountMtpObjectDirectories, g.mtpStorageInfoList[0].freeSpaceBytes,\
                "[CARD 1]" if g.countCardsUsed > 1 else ""))
    for cardIndex in xrange(1, g.countCardsUsed):
        applog_i("                     {:13,} bytes free [CARD {:d}]".format(g.mtpStorageInfoList[cardIndex].freeSpaceBytes, cardIndex+1))



#
# retrieves an MTP device property from the camera. mtpPropteryCode is a
# MTP_DeviceProp_* value. If fIgnoreIfNotSupported is TRUE then
# empty data is returned if the camera reports that the property is
# not supported.
#
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号