Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(1)  |  Call(1)  |  Derive(0)  |  Import(0)

        def getPayloadFilesFromMetafileDict(metafileDict):
  module_logger.debug("Extracting file information from metafile dictionary")
  files = []
  payloadDirectory = metafileDict['info']['name'].decode('utf-8')
  
  if utils.isSingleFileMetafile(metafileDict):
    module_logger.debug('Metafile is in single-file mode')

    filename = payloadDirectory
    module_logger.debug("  Filename => " + filename)

    size = metafileDict['info']['length']
    module_logger.debug("  Filesize => " + str(size) + " Bytes")
    
    files.append( PayloadFile(path="", filename=filename, size=size, streamOffset=0) )
  
  else:
    module_logger.debug('Metafile is in multi-file mode')
    
    numberOfFiles = len(metafileDict['info']['files'])
    module_logger.debug('Total files => ' + str(numberOfFiles))
    
    currentStreamOffset = 0
    for i in range(0, numberOfFiles):
      module_logger.debug("START: Decoding file #" + str(i+1))

      currentFile = metafileDict['info']['files'][i]
      module_logger.debug("  JSON => \n" + json.dumps(currentFile, indent=2))

      path = os.path.join(payloadDirectory, *currentFile['path'][:-1])
      module_logger.debug("  Path => " + path )

      filename = currentFile['path'][-1].decode('utf-8')
      module_logger.debug("  Filename => " + filename )

      size = currentFile['length']
      module_logger.debug("  Filesize => " + str(size) )

      index = i
      streamOffset = currentStreamOffset
      module_logger.debug("  Payload offset => " + str(streamOffset) + " Bytes")
      
      files.append( PayloadFile(path=path, filename=filename, size=size, streamOffset=streamOffset, index=index+1) )
      
      module_logger.debug("END: Decoding file #" + str(i+1))
      currentStreamOffset += size
  
  module_logger.debug("File information decoding complete!")
  return files
        


src/l/o/LocalBitTorrentFileFinder-0.2.2/lbff/BitTorrentMetafile.py   LocalBitTorrentFileFinder(Download)
def getMetafileFromDict( metafileDict ):
  module_logger.debug("Converting metafile dictionary to BitTorrentMetafile object")
  files = PayloadFile.getPayloadFilesFromMetafileDict( metafileDict )
  pieces = PayloadPiece.getPiecesFromMetafileDict( metafileDict, files )
  pieceSize = PayloadPiece.getPieceSizeFromDict(metafileDict)