]> git.lizzy.rs Git - nhentai.git/commitdiff
python3 support
authorricterz <ricterzheng@gmail.com>
Sat, 23 May 2015 07:51:18 +0000 (15:51 +0800)
committerricterz <ricterzheng@gmail.com>
Sat, 23 May 2015 07:51:18 +0000 (15:51 +0800)
nhentai/cmdline.py
nhentai/dojinshi.py
nhentai/parser.py

index 2f3b5a6640848d3cd34723cef4488eb2435f530b..26a4b5eef26f13b8565c9ef8582368ac36af5256 100644 (file)
@@ -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')
index a7b100ee1032daf90f7dc1ca393f8fa8507080aa..556c089519569aedf1f0e8e952718ebfc0445bc9 100644 (file)
@@ -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))
index 3b7082872a7442e86c82fa4f105515d2343f4f90..eda4282610816c4964c4887557d21b79e6c8fde0 100644 (file)
@@ -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))