当前位置: 首页>>代码示例>>Python>>正文


Python Book.title方法代码示例

本文整理汇总了Python中book.Book.title方法的典型用法代码示例。如果您正苦于以下问题:Python Book.title方法的具体用法?Python Book.title怎么用?Python Book.title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在book.Book的用法示例。


在下文中一共展示了Book.title方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: by_title

# 需要导入模块: from book import Book [as 别名]
# 或者: from book.Book import title [as 别名]
    def by_title(self, title):
        """
        Search for a book on OpenLibrary by title

        @param title: the title to search for
        @return: the raw data of all results
        """
        title = title.replace(' ', '+').lower()
        url = urllib.request.urlopen(self.search_url+'title='+title)
        data = simplejson.load(url)['docs']

        for result in data:
            book = Book(0)
            book.title = result['title']
            try:
                book.authors = ', '.join(result['author_name']) if isinstance(result['publisher'], list) else result['author_name']
            except KeyError:
                book.authors = "None"
            try:
                book.publisher = ', '.join(result['publisher']) if isinstance(result['publisher'], list) else result['publisher']
            except KeyError:
                book.publisher = "No publisher found."
            try:
                book.publ_year = result['first_publish_year']
            except KeyError:
                book.publ_year = 0
            try:
                book.description = ''.join(result['first_sentence'])
            except KeyError:
                book.description = "No description found."

            yield book
开发者ID:bjschafer,项目名称:pyberry,代码行数:34,代码来源:lookup.py

示例2: load_books

# 需要导入模块: from book import Book [as 别名]
# 或者: from book.Book import title [as 别名]
    def load_books(self):
        print("Loading books...")
        if self.has_books:

            accordion = self.index_soup.find('div', attrs={'id': 'accordion'})
            panels = accordion.find_all('div', attrs={'class': 'panel'})

            for panel in panels:
                book = Book()
                book.number = int(panel.find('h4').find('span', attrs={'class': 'book'}).get_text())

                if self.skip_first:
                    book.number -= 1
                    if book.number == 0:
                        continue

                book.number = str(book.number)
                if book.number not in self.chosen_books:
                    continue

                book.title = panel.find('h4').find('span', attrs={'class': 'title'}).find('a').get_text().strip()

                links = panel.find('div', attrs={'class': 'panel-body'}).find_all('a')
                for link in links:
                    book.add_chapter(Chapter(url=link.get('href'), title=link.get_text().strip()))

                self.books.append(book)
                print("Book {} done!".format(book))
开发者ID:rodrigondec,项目名称:scrapper,代码行数:30,代码来源:novel.py

示例3: _get_book_from_json_dict

# 需要导入模块: from book import Book [as 别名]
# 或者: from book.Book import title [as 别名]
    def _get_book_from_json_dict(self, data):
        """
        Create a new Book instance based on a JSON dict.

        @param data: a JSON dictionary
        @return: a new Book instance (sans ISBN)
        """
        publishers = ', '.join([self._get_publisher_from_json_dict(p) for p in data['publishers']])
        authors = ', '.join([self._get_author_from_json_dict(a) for a in data['authors']])
        book = Book(0)  # better to create an object, even if there's no valid barcode yet
        book.title = data.get('title', None)
        book.publisher = publishers
        book.authors = authors
        book.pages = data.get('number_of_pages', None)  # might cause issue, be careful.
        book.publ_year = data.get('publish_date', None)
        book.description = data.get('excerpts', None)
        return book
开发者ID:bjschafer,项目名称:pyberry,代码行数:19,代码来源:lookup.py

示例4: len

# 需要导入模块: from book import Book [as 别名]
# 或者: from book.Book import title [as 别名]
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import os
import sys
import time

from book import Book


if len(sys.argv) < 4:
    print ("Usage: %s <manga title> <export directory> <source directory...>" % sys.argv[0])
    sys.exit(1)

book = Book()
book.title = sys.argv[1]
book.directory = sys.argv[2]
directories = sys.argv[3:]

print('Sanity check:')
print('Manga title: %s' % book.title)
print('Export directory: %s' % os.path.join(unicode(book.directory), unicode(book.title)))
for dir in directories:
    print('Source directory: %s' % unicode(dir))

print('Press Ctrl-C to abort. Beginning conversion in 5 seconds...')
time.sleep(5)

# if we didn't get interrupted, begin conversion
print('Beginning conversion...')
book.addImageDirs(directories)
开发者ID:shepheb,项目名称:mangle-cli,代码行数:33,代码来源:mangle-cli.py

示例5: convert

# 需要导入模块: from book import Book [as 别名]
# 或者: from book.Book import title [as 别名]
	def convert(outputMgr, filePath, outDir, Device, verbose):
		listDir = []
		isDir = os.path.isdir(filePath)

		if (isDir):
			title = os.path.basename(filePath)
			listDir = os.listdir(filePath)
		else:
			listDir.append(filePath)
			title = 'Pictures'
			
		
		outputBook = Book()
		outputBook.DefaultDevice = Device
		
		if (title == None or title == ""):
			title = 'Pictures'
		
		files = []
		directories = []
		compressedFiles = []
		

		# Recursively loop through the filesystem
		for filename in listDir:
			if (isDir):
				filename = os.path.join(filePath, filename)
			if (verbose):
				print("Pre-Processing %s." % filename)
			if (os.path.isdir(str(filename))):	
				directories.append(filename)
			else:
				if (outputBook.isImageFile(filename)):
					if (verbose):
						print("ConvertPkg: Found Image %s" % filename)
					files.append(filename)
				else:
					imageExts = ['.cbz', '.zip']
					
					if os.path.splitext(filename)[1].lower() in imageExts:
						compressedFiles.append(filename)
		
				
		if (len(files) > 0):
			files.sort()
			outputBook.addImageFiles(files)
			outputBook.title = title
			bookConvert = BookConvert(outputBook, outputMgr, os.path.abspath(outDir), verbose)
			bookConvert.Export()			
		
		outDir = os.path.join(outDir, title)	
			
		for directory in directories:
			if(verbose):
				print("Converting %s", directory)
			convertFile.convert(outputMgr, directory, outDir, Device, verbose)
		
		for compressedFile in compressedFiles:
			try:
				if(verbose):
					print("Uncompressing %s" % compressedFile)
				z = zipfile.ZipFile(compressedFile, 'r')
			except:
				if (verbose):
					print("Failed to convert %s. Check if it is a valid zipFile." % compressedFile)
				continue
				
			if (isDir):
				temp_dir = os.path.join(filePath, os.path.splitext(os.path.basename(compressedFile))[0])
			else:
				temp_dir = os.path.splitext(compressedFile)[0]
			
			try:			
				os.mkdir(temp_dir)
			except:
				continue
				
			for name in z.namelist():
				tempName = os.path.join(temp_dir, name)
				convertFile.extract_from_zip(name, tempName, z)
			z.close
			convertFile.convert(outputMgr, temp_dir, outDir, Device, verbose)
			if os.path.exists(temp_dir):
				shutil.rmtree(temp_dir)
开发者ID:Kassino,项目名称:manga_downloader,代码行数:86,代码来源:ConvertFile.py

示例6: convert

# 需要导入模块: from book import Book [as 别名]
# 或者: from book.Book import title [as 别名]
    def convert(output_mgr, file_path, out_dir, device, verbose):
        kindle_dir = 'images' if device == 'Kindle 5' else 'Pictures'
        list_dir = []
        is_dir = os.path.isdir(file_path)

        if is_dir:
            title = os.path.basename(file_path)
            list_dir = os.listdir(file_path)
        else:
            list_dir.append(file_path)
            title = kindle_dir

        output_book = Book()
        output_book.device = device

        if title is None or title == "":
            title = kindle_dir

        files = []
        directories = []
        compressed_files = []

        # Recursively loop through the filesystem
        for filename in list_dir:
            if is_dir:
                filename = os.path.join(file_path, filename)
            if verbose:
                print("Pre-Processing %s." % filename)
            if os.path.isdir(str(filename)):
                directories.append(filename)
            else:
                if output_book.is_image_file(filename):
                    if verbose:
                        print("ConvertPkg: Found Image %s" % filename)
                    files.append(filename)
                else:
                    image_exts = ['.cbz', '.zip']

                    if os.path.splitext(filename)[1].lower() in image_exts:
                        compressed_files.append(filename)

        if len(files) > 0:
            files.sort()
            output_book.add_image_files(files)
            output_book.title = title
            book_convert = BookConvert(output_book, output_mgr, os.path.abspath(out_dir), verbose)
            book_convert.export()

        out_dir = os.path.join(out_dir, title)

        for directory in directories:
            if verbose:
                print("Converting %s", directory)
            ConvertFile.convert(output_mgr, directory, out_dir, device, verbose)

        for compressed_file in compressed_files:
            try:
                if verbose:
                    print("Uncompressing %s" % compressed_file)
                z = zipfile.ZipFile(compressed_file, 'r')
            except:
                if verbose:
                    print("Failed to convert %s. Check if it is a valid zipFile." % compressed_file)
                continue

            if is_dir:
                temp_dir = os.path.join(file_path, os.path.splitext(os.path.basename(compressed_file))[0])
            else:
                temp_dir = os.path.splitext(compressed_file)[0]

            try:
                os.mkdir(temp_dir)
            except:
                continue

            for name in z.namelist():
                temp_name = os.path.join(temp_dir, name)
                ConvertFile.extract_from_zip(name, temp_name, z)
            z.close()
            ConvertFile.convert(output_mgr, temp_dir, out_dir, device, verbose)
            if os.path.exists(temp_dir):
                shutil.rmtree(temp_dir)
开发者ID:joaquinpf,项目名称:manga_downloader,代码行数:84,代码来源:convert_file.py


注:本文中的book.Book.title方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。