Compute the number of pages in the document. It basically counts
        how many JPG files there are in the document.

def _get_nb_pages(self):
        """
        Compute the number of pages in the document. It basically counts
        how many JPG files there are in the document.
        """
        try:
            filelist = self.fs.listdir(self.path)
            count = 0
            for filepath in filelist:
                filename = self.fs.basename(filepath)
                if (filename[-4:].lower() != "." + ImgPage.EXT_IMG or
                    (filename[-10:].lower() == "." + ImgPage.EXT_THUMB) or
                    (filename[:len(ImgPage.FILE_PREFIX)].lower() !=
                        ImgPage.FILE_PREFIX)):
                    continue
                count += 1
            return count
        except IOError as exc:
            logger.debug("Exception while trying to get the number of"
                         " pages of '%s': %s", self.docid, exc)
            return 0
        except OSError as exc:
            if exc.errno != errno.ENOENT:
                logger.error("Exception while trying to get the number of"
                             " pages of '%s': %s", self.docid, exc)
                raise
            return 0