Skip to content
This repository was archived by the owner on Aug 5, 2020. It is now read-only.

Commit 71ca5a9

Browse files
committed
py2 compatibility for html and queue module
1 parent a36c67f commit 71ca5a9

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

wxpy/api/bot.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,26 @@
55
import functools
66
import logging
77
import os.path
8-
import queue
98
import tempfile
109
from pprint import pformat
1110
from threading import Thread
1211

12+
try:
13+
import queue
14+
except ImportError:
15+
# noinspection PyUnresolvedReferences,PyPep8Naming
16+
import Queue as queue
17+
1318
import itchat
1419

1520
from ..api.chats import Chat, Chats, Friend, Group, MP, User
1621
from ..api.consts import SYSTEM
1722
from ..api.messages import Message, MessageConfig, Messages, Registered
23+
from ..compatible import PY2
24+
from ..compatible.utils import force_encoded_string_output
1825
from ..utils import PuidMap
1926
from ..utils import enhance_connection, enhance_webwx_request, ensure_list, get_user_name, handle_response, \
2027
start_new_thread, wrap_user_name
21-
from ..compatible import PY2
22-
from ..compatible.utils import force_encoded_string_output
2328

2429
logger = logging.getLogger(__name__)
2530

wxpy/api/messages/message.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
# coding: utf-8
22
from __future__ import unicode_literals
33

4-
import html
54
import logging
65
import os
76
import tempfile
87
import weakref
98
from datetime import datetime
109
from xml.etree import ElementTree as ETree
1110

11+
try:
12+
import html
13+
except ImportError:
14+
# Python 2.6-2.7
15+
# noinspection PyUnresolvedReferences,PyUnresolvedReferences,PyCompatibility
16+
from HTMLParser import HTMLParser
17+
18+
html = HTMLParser()
19+
1220
from wxpy.api.chats import Chat, Group, Member, User
1321
from wxpy.compatible.utils import force_encoded_string_output
1422
from wxpy.utils import wrap_user_name

wxpy/api/messages/message_config.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
from wxpy.compatible.utils import force_encoded_string_output
88
from wxpy.utils import ensure_list
9-
from ...compatible import *
109

1110
logger = logging.getLogger(__name__)
1211

0 commit comments

Comments
 (0)