mirror of
				https://github.com/RicterZ/nhentai.git
				synced 2025-10-31 09:39:34 +01:00 
			
		
		
		
	fix unicode error on windows / python2
This commit is contained in:
		| @@ -13,8 +13,12 @@ from nhentai.utils import urlparse, generate_html | |||||||
| from nhentai.logger import logger | from nhentai.logger import logger | ||||||
|  |  | ||||||
| try: | try: | ||||||
|     reload(sys) |     if sys.version_info < (3, 0, 0): | ||||||
|     sys.setdefaultencoding(sys.stdin.encoding) |         import codecs | ||||||
|  |         import locale | ||||||
|  |         sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout) | ||||||
|  |         sys.stderr = codecs.getwriter(locale.getpreferredencoding())(sys.stderr) | ||||||
|  |  | ||||||
| except NameError: | except NameError: | ||||||
|     # python3 |     # python3 | ||||||
|     pass |     pass | ||||||
|   | |||||||
| @@ -104,6 +104,9 @@ class ColorizingStreamHandler(logging.StreamHandler): | |||||||
|                 text = parts.pop(0) |                 text = parts.pop(0) | ||||||
|  |  | ||||||
|                 if text: |                 if text: | ||||||
|  |                     if sys.version_info < (3, 0, 0): | ||||||
|  |                         write(text.encode('utf-8')) | ||||||
|  |                     else: | ||||||
|                         write(text) |                         write(text) | ||||||
|  |  | ||||||
|                 if parts: |                 if parts: | ||||||
|   | |||||||
| @@ -157,8 +157,8 @@ def print_doujinshi(doujinshi_list): | |||||||
|         return |         return | ||||||
|     doujinshi_list = [(i['id'], i['title']) for i in doujinshi_list] |     doujinshi_list = [(i['id'], i['title']) for i in doujinshi_list] | ||||||
|     headers = ['id', 'doujinshi'] |     headers = ['id', 'doujinshi'] | ||||||
|     logger.info('Search Result\n' + |     data = tabulate(tabular_data=doujinshi_list, headers=headers, tablefmt='rst') | ||||||
|                 tabulate(tabular_data=doujinshi_list, headers=headers, tablefmt='rst')) |     logger.info('Search Result\n{}'.format(data)) | ||||||
|  |  | ||||||
|  |  | ||||||
| def tag_parser(tag_id): | def tag_parser(tag_id): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user