PyPtt 2.1.5__tar.gz → 2.1.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyptt-2.1.5 → pyptt-2.1.6}/PKG-INFO +1 -1
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/__init__.py +1 -1
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_get_newest_index.py +1 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_get_post.py +1 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_mail.py +15 -0
- pyptt-2.1.6/PyPtt/ssl_config.py +24 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt.egg-info/PKG-INFO +1 -1
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_get_mail.py +48 -0
- pyptt-2.1.5/PyPtt/ssl_config.py +0 -24
- {pyptt-2.1.5 → pyptt-2.1.6}/LICENSE +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/PTT.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_bucket.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_call_status.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_change_pw.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_comment.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_del_post.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_get_board_info.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_get_board_list.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_get_bottom_post_list.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_get_favourite_board.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_get_post_index.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_get_post_list.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_get_time.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_get_user.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_get_waterball.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_give_money.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_has_new_mail.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_loginout.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_mark_post.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_post.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_reply_post.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_search_user.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_set_board_title.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/_api_util.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/api_server.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/check_value.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/command.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/config.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/connect_core.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/data_type.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/exceptions.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/i18n.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/lang_en_US.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/lang_zh_TW.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/lib_util.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/log.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/screens.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt/service.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt.egg-info/SOURCES.txt +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt.egg-info/dependency_links.txt +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt.egg-info/requires.txt +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/PyPtt.egg-info/top_level.txt +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/README.md +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/pyproject.toml +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/setup.cfg +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/setup.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_bucket.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_change_pw.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_comment.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_del_post.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_exceptions.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_fast_post.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_get_board_info.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_get_board_list.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_get_bottom_post_list.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_get_content_formula.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_get_favourite_boards.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_get_newest_index.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_get_post.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_get_post_list.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_get_post_list_parser.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_get_post_parser.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_get_time.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_get_user.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_get_waterball.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_give_money.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_i18n.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_init.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_logger.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_login_logout.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_mail_send_and_del.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_mark_post.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_parse_query_post.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_post.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_pyte_parity.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_reply_post.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_search_user.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_service.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_set_board_title.py +0 -0
- {pyptt-2.1.5 → pyptt-2.1.6}/tests/test_vt100_parser.py +0 -0
|
@@ -65,6 +65,7 @@ def get_newest_index(api, index_type: data_type.NewIndex, board: Optional[str] =
|
|
|
65
65
|
search_list = []
|
|
66
66
|
else:
|
|
67
67
|
check_value.check_type(search_list, list, 'search_list')
|
|
68
|
+
search_list = list(search_list) # 別就地改到呼叫端傳進來的 list
|
|
68
69
|
|
|
69
70
|
if (search_type, search_condition) != (None, None):
|
|
70
71
|
search_list.insert(0, (search_type, search_condition))
|
|
@@ -39,6 +39,7 @@ def get_post(api, board: str, aid: Optional[str] = None, index: Optional[int] =
|
|
|
39
39
|
search_list = []
|
|
40
40
|
else:
|
|
41
41
|
check_value.check_type(search_list, list, 'search_list')
|
|
42
|
+
search_list = list(search_list) # 別就地改到呼叫端傳進來的 list
|
|
42
43
|
|
|
43
44
|
if (search_type, search_condition) != (None, None):
|
|
44
45
|
search_list.insert(0, (search_type, search_condition))
|
|
@@ -146,6 +146,21 @@ def get_mail(api, index: int, search_type: Optional[data_type.SearchType] = None
|
|
|
146
146
|
cmd_list.append(command.ctrl_z)
|
|
147
147
|
cmd_list.append('m')
|
|
148
148
|
|
|
149
|
+
# search_type/search_condition 併入 search_list(比照 get_post),
|
|
150
|
+
# 否則單獨使用 search_type 搜尋會被忽略。
|
|
151
|
+
if search_list is None:
|
|
152
|
+
search_list = []
|
|
153
|
+
else:
|
|
154
|
+
check_value.check_type(search_list, list, 'search_list')
|
|
155
|
+
search_list = list(search_list) # 別就地改到呼叫端傳進來的 list
|
|
156
|
+
|
|
157
|
+
if (search_type, search_condition) != (None, None):
|
|
158
|
+
search_list.insert(0, (search_type, search_condition))
|
|
159
|
+
|
|
160
|
+
for search_type, search_condition in search_list:
|
|
161
|
+
check_value.check_type(search_type, data_type.SearchType, 'search_type')
|
|
162
|
+
check_value.check_type(search_condition, str, 'search_condition')
|
|
163
|
+
|
|
149
164
|
# 處理條件整理出指令
|
|
150
165
|
_cmd_list = _api_util.get_search_condition_cmd(data_type.NewIndex.MAIL, search_list)
|
|
151
166
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
key = """-----BEGI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Hn
|
|
21
|
+
waVAljYZrhuUwCQxcibRzy006NsenvmTLLwCIQDuQAAsbdtAfswclkrDHBtoCeCl
|
|
22
|
+
VphR8OhIzsjJE7SKjA==
|
|
23
|
+
-----END CERTIFICATE-----
|
|
24
|
+
"""
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import PyPtt
|
|
2
2
|
import pytest
|
|
3
3
|
|
|
4
|
+
from PyPtt import _api_mail, _api_util, data_type
|
|
5
|
+
|
|
4
6
|
|
|
5
7
|
def _handle_empty_mailbox(ptt_bot):
|
|
6
8
|
"""On LOCALHOST, scripts/bootstrap_local_pttbbs.py always sends each bot a
|
|
@@ -14,6 +16,52 @@ def _handle_empty_mailbox(ptt_bot):
|
|
|
14
16
|
"so this indicates a real regression, not an environment quirk.")
|
|
15
17
|
|
|
16
18
|
|
|
19
|
+
def test_get_mail_search_type_is_honored(monkeypatch):
|
|
20
|
+
"""Regression: get_mail must merge search_type/search_condition into the
|
|
21
|
+
mail search command, the same way get_newest_index does. They were
|
|
22
|
+
previously ignored, so `get_mail(index, search_type=AUTHOR, ...)` returned
|
|
23
|
+
the unfiltered mail at that index instead of the author-filtered one.
|
|
24
|
+
|
|
25
|
+
Offline unit test: captures the search_list handed to the command builder
|
|
26
|
+
and stops before any PTT navigation. (log/i18n are initialised by the
|
|
27
|
+
autouse ptt_bots fixture, which constructs PyPtt.API before this runs.)"""
|
|
28
|
+
|
|
29
|
+
class _StopBeforeNetwork(Exception):
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
captured = {}
|
|
33
|
+
|
|
34
|
+
def fake_cmd(index_type, search_list):
|
|
35
|
+
captured["search_list"] = search_list
|
|
36
|
+
raise _StopBeforeNetwork
|
|
37
|
+
|
|
38
|
+
monkeypatch.setattr(_api_util, "one_thread", lambda api: None)
|
|
39
|
+
monkeypatch.setattr(_api_util, "get_search_condition_cmd", fake_cmd)
|
|
40
|
+
|
|
41
|
+
class _FakeAPI:
|
|
42
|
+
_is_login = True
|
|
43
|
+
is_registered_user = True
|
|
44
|
+
|
|
45
|
+
def get_newest_index(self, *a, **k):
|
|
46
|
+
return 999
|
|
47
|
+
|
|
48
|
+
# search_type/search_condition alone (no search_list) must reach the builder.
|
|
49
|
+
# Both the enum and its string name are accepted (SearchType._MagicMeta lets
|
|
50
|
+
# isinstance('AUTHOR', SearchType) pass), matching get_post's validation loop.
|
|
51
|
+
for st in ("AUTHOR", data_type.SearchType.AUTHOR):
|
|
52
|
+
captured.clear()
|
|
53
|
+
with pytest.raises(_StopBeforeNetwork):
|
|
54
|
+
_api_mail.get_mail(_FakeAPI(), index=3, search_type=st,
|
|
55
|
+
search_condition="someone")
|
|
56
|
+
assert captured["search_list"] == [(st, "someone")]
|
|
57
|
+
|
|
58
|
+
# no search -> no filter (unchanged behaviour)
|
|
59
|
+
captured.clear()
|
|
60
|
+
with pytest.raises(_StopBeforeNetwork):
|
|
61
|
+
_api_mail.get_mail(_FakeAPI(), index=1)
|
|
62
|
+
assert captured["search_list"] == []
|
|
63
|
+
|
|
64
|
+
|
|
17
65
|
def test_get_newest_mail(ptt_bots):
|
|
18
66
|
"""Tests getting the newest mail from the mailbox."""
|
|
19
67
|
verified = False
|
pyptt-2.1.5/PyPtt/ssl_config.py
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
key = """-----BEGIN EC PARAMETERS-----
|
|
2
|
-
BggqhkjOPQMBBw==
|
|
3
|
-
-----END EC PARAMETERS-----
|
|
4
|
-
-----BEGIN EC PRIVATE KEY-----
|
|
5
|
-
MHcCAQEEIF0fyzVzlWVfbwf0IkWdOi1DD6g4dl2Wf2MSaPKS2pRtoAoGCCqGSM49
|
|
6
|
-
AwEHoUQDQgAEvsTkmHxvh9EMh+1wFd+Z8bN0bLOWisGv3uNP0qeV0jy88cmPTWRl
|
|
7
|
-
OzU8emmKTJZpuoOEGqi/Ow4vo+WTxMPynQ==
|
|
8
|
-
-----END EC PRIVATE KEY-----
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
cert = """-----BEGIN CERTIFICATE-----
|
|
12
|
-
MIIB6TCCAY8CFGi0fucoS9ysCrt9pKAu9BgMAULWMAoGCCqGSM49BAMCMHcxCzAJ
|
|
13
|
-
BgNVBAYTAlRXMQ4wDAYDVQQIDAVTdGF0ZTENMAsGA1UEBwwEQ2l0eTEVMBMGA1UE
|
|
14
|
-
CgwMT3JnYW5pemF0aW9uMRwwGgYDVQQLDBNPcmdhbml6YXRpb25hbCBVbml0MRQw
|
|
15
|
-
EgYDVQQDDAtDb21tb24gTmFtZTAeFw0yNjA3MTgwMTIwNTlaFw0zNjA3MTUwMTIw
|
|
16
|
-
NTlaMHcxCzAJBgNVBAYTAlRXMQ4wDAYDVQQIDAVTdGF0ZTENMAsGA1UEBwwEQ2l0
|
|
17
|
-
eTEVMBMGA1UECgwMT3JnYW5pemF0aW9uMRwwGgYDVQQLDBNPcmdhbml6YXRpb25h
|
|
18
|
-
bCBVbml0MRQwEgYDVQQDDAtDb21tb24gTmFtZTBZMBMGByqGSM49AgEGCCqGSM49
|
|
19
|
-
AwEHA0IABL7E5Jh8b4fRDIftcBXfmfGzdGyzlorBr97jT9KnldI8vPHJj01kZTs1
|
|
20
|
-
PHppikyWabqDhBqovzsOL6Plk8TD8p0wCgYIKoZIzj0EAwIDSAAwRQIgYTfmCpJN
|
|
21
|
-
abcPTvASZb/a7vanhO1vpafJ6Hlff6pAxh0CIQCl/Vvrx6DV21rUC3rkHBOFeqev
|
|
22
|
-
I9Izuv9PxfLpnxoFcw==
|
|
23
|
-
-----END CERTIFICATE-----
|
|
24
|
-
"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|