Logo Search packages:      
Sourcecode: calibre version File versions

def calibre::devices::prs500::driver::PRS500::upload_books (   self,
  on_card = False,
  end_session = True,
  metadata = None 

Upload a list of books to the device. If a file already
exists on the device, it should be replaced.
This method should raise a L{FreeSpaceError} if there is not enough
free space on the device. The text of the FreeSpaceError must contain the
word "card" if C{on_card} is not None otherwise it must contain the word "memory".
@param files: A list of paths and/or file-like objects.
@param names: A list of file names that the books should have
once uploaded to the device. len(names) == len(files)
@return: A list of 3-element tuples. The list is meant to be passed
to L{add_books_to_metadata}.
@param metadata: If not None, it is a list of dictionaries. Each dictionary
will have at least the key tags to allow the driver to choose book location
based on tags. len(metadata) == len(files). If your device does not support
hierarchical ebook folders, you can safely ignore this parameter.

Reimplemented from calibre::devices::interface::DevicePlugin.

Definition at line 870 of file driver.py.

        card = self.card(end_session=False)
        prefix = card + '/' + self.CARD_PATH_PREFIX +'/' if on_card else '/Data/media/books/'
        if on_card and not self._exists(prefix)[0]:
            self.mkdir(prefix[:-1], False)
        paths, ctimes = [], []
        names = iter(names)
        infiles = [file if hasattr(file, 'read') else open(file, 'rb') for file in files]
        for f in infiles: f.seek(0, 2)
        sizes = [f.tell() for f in infiles]
        size = sum(sizes)
        space = self.free_space(end_session=False)
        mspace = space[0]
        cspace = space[2] if len(space) > 2 and space[2] >= space[1] else  space[1]
        if on_card and size > cspace - 1024*1024:
            raise FreeSpaceError("There is insufficient free space "+\
                                          "on the storage card")
        if not on_card and size > mspace - 2*1024*1024:
            raise FreeSpaceError("There is insufficient free space " +\
                                         "in main memory")

        for infile in infiles:
            name = names.next()
            self.put_file(infile, paths[-1], replace_file=True, end_session=False)
            ctimes.append(self.path_properties(paths[-1], end_session=False).ctime)
        return zip(paths, sizes, ctimes)

    def add_books_to_metadata(cls, locations, metadata, booklists):

Generated by  Doxygen 1.6.0   Back to index