diff --git a/nhentai/cmdline.py b/nhentai/cmdline.py index 2f3b5a6..26a4b5e 100644 --- a/nhentai/cmdline.py +++ b/nhentai/cmdline.py @@ -1,16 +1,20 @@ #coding: utf-8 +from __future__ import print_function from optparse import OptionParser -from itertools import ifilter from logger import logger +try: + from itertools import ifilter as filter +except ImportError: + pass def banner(): - print ''' _ _ _ _ + print(''' _ _ _ _ _ __ | | | | ___ _ __ | |_ __ _(_) | '_ \| |_| |/ _ \ '_ \| __/ _` | | | | | | _ | __/ | | | || (_| | | |_| |_|_| |_|\___|_| |_|\__\__,_|_| -''' +''') def cmd_parser(): @@ -31,7 +35,7 @@ def cmd_parser(): if args.ids: _ = map(lambda id: id.strip(), args.ids.split(',')) - args.ids = set(map(int, ifilter(lambda id: id.isdigit(), _))) + args.ids = set(map(int, filter(lambda id: id.isdigit(), _))) if args.is_download and not args.id and not args.ids and not args.keyword: logger.critical('Dojinshi id/ids is required for downloading') diff --git a/nhentai/dojinshi.py b/nhentai/dojinshi.py index a7b100e..556c089 100644 --- a/nhentai/dojinshi.py +++ b/nhentai/dojinshi.py @@ -1,3 +1,4 @@ +from __future__ import print_function from constant import DETAIL_URL, IMAGE_URL from logger import logger @@ -18,10 +19,10 @@ class Dojinshi(object): def show(self): logger.info('Print dojinshi information') - print 'Dojinshi: %s' % self.name - print 'Subtitle: %s' % self.subtitle - print 'URL: %s' % self.url - print 'Pages: %d' % self.pages + print('Dojinshi: %s' % self.name) + print('Subtitle: %s' % self.subtitle) + print('URL: %s' % self.url) + print('Pages: %d' % self.pages) def download(self): logger.info('Start download dojinshi: %s' % self.name) @@ -36,9 +37,9 @@ class Dojinshi(object): if __name__ == '__main__': test = Dojinshi(name='test nhentai dojinshi', id=1) - print test + print(test) test.show() try: test.download() except Exception as e: - print 'Exception: %s' % str(e) \ No newline at end of file + print('Exception: %s' % str(e)) diff --git a/nhentai/parser.py b/nhentai/parser.py index 3b70828..eda4282 100644 --- a/nhentai/parser.py +++ b/nhentai/parser.py @@ -1,3 +1,4 @@ +from __future__ import print_function import sys import re import requests @@ -66,11 +67,11 @@ def print_dojinshi(dojinshi_list): if not dojinshi_list: return logger.log(15, 'Print dojinshi list') - print '-' * 60 + print('-' * 60) for dojinshi in dojinshi_list: - print dojinshi['id'], '-', dojinshi['title'] - print '-' * 60 + print(dojinshi['id'], '-', dojinshi['title']) + print('-' * 60) if __name__ == '__main__': - print dojinshi_parser(32271) \ No newline at end of file + print(dojinshi_parser(32271))