From 6aa25cb0c85e665af40abb151b801e4261c57c6e Mon Sep 17 00:00:00 2001
From: Starry-OvO
Date: Sat, 26 Aug 2023 21:32:24 +0800
Subject: [PATCH 01/11] refactor: rename `_python.h` to `pywrap.h`
---
aiotieba/__version__.py | 2 +-
.../helper/crypto/include/tbcrypto/{_python.h => pywrap.h} | 6 +++---
aiotieba/helper/crypto/include/tbcrypto/sign.h | 2 +-
aiotieba/helper/crypto/src/tbcrypto/lib.c | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
rename aiotieba/helper/crypto/include/tbcrypto/{_python.h => pywrap.h} (90%)
diff --git a/aiotieba/__version__.py b/aiotieba/__version__.py
index 975f6914..2a962374 100644
--- a/aiotieba/__version__.py
+++ b/aiotieba/__version__.py
@@ -1 +1 @@
-__version__ = "3.7.1"
+__version__ = "3.7.2a0"
diff --git a/aiotieba/helper/crypto/include/tbcrypto/_python.h b/aiotieba/helper/crypto/include/tbcrypto/pywrap.h
similarity index 90%
rename from aiotieba/helper/crypto/include/tbcrypto/_python.h
rename to aiotieba/helper/crypto/include/tbcrypto/pywrap.h
index 1640135a..7518799c 100644
--- a/aiotieba/helper/crypto/include/tbcrypto/_python.h
+++ b/aiotieba/helper/crypto/include/tbcrypto/pywrap.h
@@ -2,7 +2,9 @@
#define PY_SSIZE_T_CLEAN // use Py_ssize_t instead of int
-#ifdef TBC_FORCE_PYTHON_NODEBUG
+#ifdef TBC_PYTHON_DEBUG
+#include
+#else
#ifdef _DEBUG
#undef _DEBUG // use these steps to avoid linking with python_d.lib
#define __TBC_RESTORE_DEBUG
@@ -12,6 +14,4 @@
#define _DEBUG
#undef __TBC_RESTORE_DEBUG
#endif
-#else
-#include
#endif
diff --git a/aiotieba/helper/crypto/include/tbcrypto/sign.h b/aiotieba/helper/crypto/include/tbcrypto/sign.h
index 75690485..9688e6c1 100644
--- a/aiotieba/helper/crypto/include/tbcrypto/sign.h
+++ b/aiotieba/helper/crypto/include/tbcrypto/sign.h
@@ -1,5 +1,5 @@
#pragma once
-#include "tbcrypto/_python.h"
+#include "tbcrypto/pywrap.h"
PyObject* sign(PyObject* Py_UNUSED(self), PyObject* args);
diff --git a/aiotieba/helper/crypto/src/tbcrypto/lib.c b/aiotieba/helper/crypto/src/tbcrypto/lib.c
index 8e4f0399..b351fca6 100644
--- a/aiotieba/helper/crypto/src/tbcrypto/lib.c
+++ b/aiotieba/helper/crypto/src/tbcrypto/lib.c
@@ -1,4 +1,4 @@
-#include "tbcrypto/_python.h"
+#include "tbcrypto/pywrap.h"
#include "tbcrypto/const.h"
#include "tbcrypto/cuid.h"
From 1be683c50a22d83e07e83188eeab95e70e7a51c2 Mon Sep 17 00:00:00 2001
From: Starry-OvO
Date: Sun, 27 Aug 2023 10:08:31 +0800
Subject: [PATCH 02/11] chore: add scripts
---
.gitignore | 2 ++
scripts/proto_compile.py | 48 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+)
create mode 100644 scripts/proto_compile.py
diff --git a/.gitignore b/.gitignore
index 17aaed5e..4730e97f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,6 +17,8 @@
!docs/**
!tests
!tests/**
+!scripts
+!scripts/**
*.py[cd]
__pycache__
diff --git a/scripts/proto_compile.py b/scripts/proto_compile.py
new file mode 100644
index 00000000..c00b4040
--- /dev/null
+++ b/scripts/proto_compile.py
@@ -0,0 +1,48 @@
+import subprocess
+from pathlib import Path
+
+commom_proto_pth = Path("aiotieba/api/_protobuf")
+
+for fpth in commom_proto_pth.glob('*_pb2.py'):
+ fpth.unlink()
+
+subprocess.run("protoc --python_out=. *.proto", cwd=str(commom_proto_pth), check=True, timeout=60.0)
+
+for fpth in commom_proto_pth.glob('*_pb2.py'):
+ bak_fpth = fpth.with_suffix('.bak')
+ with (
+ fpth.open('r') as f,
+ bak_fpth.open('w') as bak_f,
+ ):
+ for row in f.readlines():
+ if row.startswith('#'):
+ continue
+ if row.startswith('import'):
+ row = "from . " + row
+ bak_f.write(row)
+ fpth.unlink()
+ bak_fpth.rename(fpth)
+
+for mod_pth in Path("aiotieba/api").glob('*/protobuf'):
+ for fpth in mod_pth.glob('*_pb2.py'):
+ fpth.unlink()
+
+ subprocess.run("protoc -I../../_protobuf -I. --python_out=. *.proto", cwd=str(mod_pth), check=True, timeout=10.0)
+
+ for fpth in mod_pth.glob('*_pb2.py'):
+ bak_fpth = fpth.with_suffix('.bak')
+ with (
+ fpth.open('r') as f,
+ bak_fpth.open('w') as bak_f,
+ ):
+ for row in f.readlines():
+ if row.startswith('#'):
+ continue
+ if row.startswith('import'):
+ row = "from ..._protobuf " + row
+ bak_f.write(row)
+ fpth.unlink()
+ bak_fpth.rename(fpth)
+
+subprocess.run("ruff . --fix", cwd='.', check=False, timeout=10.0)
+subprocess.run("black .", cwd='.', check=False, timeout=30.0)
From a71c2f226665b185e3ac8d3b747386abe574fc2c Mon Sep 17 00:00:00 2001
From: Starry-OvO
Date: Sun, 27 Aug 2023 10:17:21 +0800
Subject: [PATCH 03/11] refactor: rename `zid.h` to `rc442.h`
---
aiotieba/helper/crypto/include/tbcrypto/{zid.h => rc442.h} | 0
aiotieba/helper/crypto/src/tbcrypto/lib.c | 2 +-
aiotieba/helper/crypto/src/tbcrypto/{zid.c => rc442.c} | 2 +-
3 files changed, 2 insertions(+), 2 deletions(-)
rename aiotieba/helper/crypto/include/tbcrypto/{zid.h => rc442.h} (100%)
rename aiotieba/helper/crypto/src/tbcrypto/{zid.c => rc442.c} (98%)
diff --git a/aiotieba/helper/crypto/include/tbcrypto/zid.h b/aiotieba/helper/crypto/include/tbcrypto/rc442.h
similarity index 100%
rename from aiotieba/helper/crypto/include/tbcrypto/zid.h
rename to aiotieba/helper/crypto/include/tbcrypto/rc442.h
diff --git a/aiotieba/helper/crypto/src/tbcrypto/lib.c b/aiotieba/helper/crypto/src/tbcrypto/lib.c
index b351fca6..81b37341 100644
--- a/aiotieba/helper/crypto/src/tbcrypto/lib.c
+++ b/aiotieba/helper/crypto/src/tbcrypto/lib.c
@@ -3,8 +3,8 @@
#include "tbcrypto/const.h"
#include "tbcrypto/cuid.h"
#include "tbcrypto/error.h"
+#include "tbcrypto/rc442.h"
#include "tbcrypto/sign.h"
-#include "tbcrypto/zid.h"
PyObject* cuid_galaxy2(PyObject* Py_UNUSED(self), PyObject* args)
{
diff --git a/aiotieba/helper/crypto/src/tbcrypto/zid.c b/aiotieba/helper/crypto/src/tbcrypto/rc442.c
similarity index 98%
rename from aiotieba/helper/crypto/src/tbcrypto/zid.c
rename to aiotieba/helper/crypto/src/tbcrypto/rc442.c
index 42a5db2c..cd515d01 100644
--- a/aiotieba/helper/crypto/src/tbcrypto/zid.c
+++ b/aiotieba/helper/crypto/src/tbcrypto/rc442.c
@@ -3,7 +3,7 @@
#include "tbcrypto/const.h"
#include "tbcrypto/error.h"
-#include "tbcrypto/zid.h"
+#include "tbcrypto/rc442.h"
typedef struct rc4_42_context {
int x;
From 92b15ac5d92a6edf8b1495e32016f1c6ed97f618 Mon Sep 17 00:00:00 2001
From: Starry-OvO
Date: Sun, 27 Aug 2023 22:21:52 +0800
Subject: [PATCH 04/11] chore: introduce pbm
---
.github/workflows/Pages.yml | 6 ++---
.github/workflows/Publish.yml | 51 +++++++++++++++++------------------
README.md | 4 +++
docs/index.md | 4 +++
pyproject.toml | 7 +++--
5 files changed, 41 insertions(+), 31 deletions(-)
diff --git a/.github/workflows/Pages.yml b/.github/workflows/Pages.yml
index dd66784e..491d06be 100644
--- a/.github/workflows/Pages.yml
+++ b/.github/workflows/Pages.yml
@@ -34,12 +34,12 @@ jobs:
- name: Install dependencies
run: |
- pip install -U pip -qq
- pip install mkdocs-material mkdocstrings[python] -qq
+ pipx install pdm
+ pdm install -G doc
- name: Build
run: |
- mkdocs build -d site -s
+ pdm run mkdocs build -d site -s
- name: Upload Artifact
uses: actions/upload-pages-artifact@v2
diff --git a/.github/workflows/Publish.yml b/.github/workflows/Publish.yml
index 88f9afce..41fa407e 100644
--- a/.github/workflows/Publish.yml
+++ b/.github/workflows/Publish.yml
@@ -17,17 +17,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- - uses: actions/setup-python@v4
- with:
- python-version: "3.x"
-
- - name: Install cibuildwheel
- run: pip install cibuildwheel -qq
-
- name: Build wheels
- run: python -m cibuildwheel --output-dir wheelhouse
+ uses: pypa/cibuildwheel@v2
env:
- CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* pp38-* pp39-*"
+ CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* pp38-* pp39-* pp310-*"
CIBW_SKIP: "*-win32 *_i686 *_s390x *_ppc64le"
- uses: actions/upload-artifact@v3
@@ -35,38 +28,44 @@ jobs:
name: dist
path: ./wheelhouse/*.whl
+ build_sdist:
+ name: Build source distribution
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Build sdist
+ run: pipx run build --sdist
+
+ - uses: actions/upload-artifact@v3
+ with:
+ path: dist/*.tar.gz
+
publish:
name: Publish
- needs: build_wheels
+ needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment:
- name: publish
+ name: pypi
+ url: https://pypi.org/p/aiotieba
- env:
- PYTHON_VER: "3.11"
+ permissions:
+ id-token: write
steps:
- - name: Set up Python ${{ env.PYTHON_VER }}
- uses: actions/setup-python@v4
- with:
- python-version: ${{ env.PYTHON_VER }}
-
- - name: Install dependencies
- run: |
- python -m pip install -U pip -qq
- pip install -U twine -qq
-
- name: Download distributions
uses: actions/download-artifact@v3
with:
- name: dist
+ name: artifact
path: dist
- name: Publish to PyPI
if: ${{ github.event_name == 'push' }}
- run: twine upload dist/* -u __token__ -p ${{ secrets.PYPI_TOKEN }} --disable-progress-bar
+ uses: pypa/gh-action-pypi-publish@release/v1
- name: Publish to TestPyPI
if: ${{ github.event_name == 'workflow_dispatch' }}
- run: twine upload -r testpypi dist/* -u __token__ -p ${{ secrets.TESTPYPI_TOKEN }} --disable-progress-bar
+ uses: pypa/gh-action-pypi-publish@release/v1
+ with:
+ repository-url: https://test.pypi.org/legacy/
diff --git a/README.md b/README.md
index 86ee1647..b22db3a0 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,10 @@
+
+
+
+
diff --git a/docs/index.md b/docs/index.md
index 1f1d3fcb..f07bd572 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -18,6 +18,10 @@
+
+
+
+
---
diff --git a/pyproject.toml b/pyproject.toml
index c77f743d..b3083139 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -69,10 +69,14 @@ version = { attr = "aiotieba.__version__.__version__" }
[tool.setuptools.package-data]
"*" = ["*.pyi"]
+[tool.pdm.dev-dependencies]
+test = ["aiotieba[speedup]", "pytest", "pytest-asyncio", "pytest-rerunfailures"]
+doc = ["mkdocs-material", "mkdocstrings[python]"]
+
[tool.black]
line-length = 120
skip-string-normalization = true
-target-version = ["py38"]
+target-version = ["py38", "py39", "py310", "py311"]
[tool.ruff]
line-length = 120
@@ -86,7 +90,6 @@ target-version = "py38"
"*_pb2.py" = ["F401"]
[tool.pytest.ini_options]
-minversion = "6.0"
addopts = "-q"
testpaths = ["tests"]
required_plugins = "pytest-asyncio pytest-rerunfailures"
From 3de70b3e9801557dad7f5d756d6e957ac12ae36d Mon Sep 17 00:00:00 2001
From: Starry-OvO
Date: Sun, 27 Aug 2023 22:33:02 +0800
Subject: [PATCH 05/11] docs: simplify CI
---
.github/workflows/Pages.yml | 12 ++----------
.github/workflows/Publish.yml | 2 +-
2 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/.github/workflows/Pages.yml b/.github/workflows/Pages.yml
index 491d06be..2e509655 100644
--- a/.github/workflows/Pages.yml
+++ b/.github/workflows/Pages.yml
@@ -20,22 +20,14 @@ jobs:
build:
runs-on: ubuntu-latest
- env:
- PYTHON_VER: "3.11"
-
steps:
- name: Checkout
uses: actions/checkout@v3
- - name: Setup Python ${{ env.PYTHON_VER }}
- uses: actions/setup-python@v4
- with:
- python-version: ${{ env.PYTHON_VER }}
-
- name: Install dependencies
run: |
- pipx install pdm
- pdm install -G doc
+ pipx install pdm --python
+ pdm install -G doc --no-default
- name: Build
run: |
diff --git a/.github/workflows/Publish.yml b/.github/workflows/Publish.yml
index 41fa407e..b6b7e445 100644
--- a/.github/workflows/Publish.yml
+++ b/.github/workflows/Publish.yml
@@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@v3
- name: Build wheels
- uses: pypa/cibuildwheel@v2
+ uses: pypa/cibuildwheel@v2.15.0
env:
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* pp38-* pp39-* pp310-*"
CIBW_SKIP: "*-win32 *_i686 *_s390x *_ppc64le"
From 7dbf1851cc6b88ce93868f5ab2e87e2381556edc Mon Sep 17 00:00:00 2001
From: Starry-OvO
Date: Sun, 27 Aug 2023 22:33:58 +0800
Subject: [PATCH 06/11] fix: CI Pages
---
.github/workflows/Pages.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/Pages.yml b/.github/workflows/Pages.yml
index 2e509655..be20a331 100644
--- a/.github/workflows/Pages.yml
+++ b/.github/workflows/Pages.yml
@@ -26,7 +26,7 @@ jobs:
- name: Install dependencies
run: |
- pipx install pdm --python
+ pipx install pdm
pdm install -G doc --no-default
- name: Build
From ef2b31db24b9edad43c1d64378b8a604db90e345 Mon Sep 17 00:00:00 2001
From: Starry-OvO
Date: Sun, 27 Aug 2023 22:54:04 +0800
Subject: [PATCH 07/11] fix: failed to upload artifacts
---
.github/workflows/Publish.yml | 2 --
1 file changed, 2 deletions(-)
diff --git a/.github/workflows/Publish.yml b/.github/workflows/Publish.yml
index b6b7e445..4d3b79d9 100644
--- a/.github/workflows/Publish.yml
+++ b/.github/workflows/Publish.yml
@@ -25,7 +25,6 @@ jobs:
- uses: actions/upload-artifact@v3
with:
- name: dist
path: ./wheelhouse/*.whl
build_sdist:
@@ -48,7 +47,6 @@ jobs:
environment:
name: pypi
- url: https://pypi.org/p/aiotieba
permissions:
id-token: write
From da582f91e6b7721b893d231f296825768a6c12d7 Mon Sep 17 00:00:00 2001
From: Starry-OvO
Date: Tue, 29 Aug 2023 08:26:35 +0800
Subject: [PATCH 08/11] fix: `Forum_detail.has_bawu`
---
aiotieba/__version__.py | 2 +-
aiotieba/api/get_forum_detail/_classdef.py | 2 +-
pyproject.toml | 1 +
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/aiotieba/__version__.py b/aiotieba/__version__.py
index 2a962374..102f418d 100644
--- a/aiotieba/__version__.py
+++ b/aiotieba/__version__.py
@@ -1 +1 @@
-__version__ = "3.7.2a0"
+__version__ = "3.7.2a1"
diff --git a/aiotieba/api/get_forum_detail/_classdef.py b/aiotieba/api/get_forum_detail/_classdef.py
index 8e07a186..b3e89cd7 100644
--- a/aiotieba/api/get_forum_detail/_classdef.py
+++ b/aiotieba/api/get_forum_detail/_classdef.py
@@ -41,7 +41,7 @@ def __init__(self, data_proto: Optional[TypeMessage] = None) -> None:
self._slogan = forum_proto.slogan
self._member_num = forum_proto.member_count
self._post_num = forum_proto.thread_count
- self._has_bawu = bool(data_proto.election_tab.new_manager_status)
+ self._has_bawu = data_proto.election_tab.new_manager_status == 5
else:
self._fid = 0
self._fname = ''
diff --git a/pyproject.toml b/pyproject.toml
index b3083139..64821b95 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -70,6 +70,7 @@ version = { attr = "aiotieba.__version__.__version__" }
"*" = ["*.pyi"]
[tool.pdm.dev-dependencies]
+lint = ["ruff", "black"]
test = ["aiotieba[speedup]", "pytest", "pytest-asyncio", "pytest-rerunfailures"]
doc = ["mkdocs-material", "mkdocstrings[python]"]
From 601b94a3109c6695ae103ec8cb210cd5e33b304e Mon Sep 17 00:00:00 2001
From: Starry-OvO
Date: Thu, 31 Aug 2023 08:04:32 +0800
Subject: [PATCH 09/11] fix: `get_bawu_postlogs` failed to parse medias
---
aiotieba/__version__.py | 2 +-
aiotieba/api/get_bawu_postlogs/_classdef.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/aiotieba/__version__.py b/aiotieba/__version__.py
index 102f418d..f2eeedd6 100644
--- a/aiotieba/__version__.py
+++ b/aiotieba/__version__.py
@@ -1 +1 @@
-__version__ = "3.7.2a1"
+__version__ = "3.7.2a2"
diff --git a/aiotieba/api/get_bawu_postlogs/_classdef.py b/aiotieba/api/get_bawu_postlogs/_classdef.py
index 81bf8125..d03093a6 100644
--- a/aiotieba/api/get_bawu_postlogs/_classdef.py
+++ b/aiotieba/api/get_bawu_postlogs/_classdef.py
@@ -119,7 +119,7 @@ def __init__(self, data_tag: bs4.element.Tag) -> None:
text_item = post_content_item.div
self._text = text_item.string[12:]
- self._medias = [Media_postlog(tag) for tag in text_item.next_sibling('a')]
+ self._medias = [Media_postlog(tag) for tag in text_item.next_sibling('a', class_=None)]
op_type_item = left_cell_item.next_sibling
self._op_type = op_type_item.string
From 0ac506dc06a75130ed6d0ec077fb60506716b64e Mon Sep 17 00:00:00 2001
From: Starry-OvO
Date: Thu, 31 Aug 2023 11:22:39 +0800
Subject: [PATCH 10/11] chore: update workflow Pages
---
.github/workflows/Pages.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/Pages.yml b/.github/workflows/Pages.yml
index be20a331..cc482129 100644
--- a/.github/workflows/Pages.yml
+++ b/.github/workflows/Pages.yml
@@ -27,7 +27,7 @@ jobs:
- name: Install dependencies
run: |
pipx install pdm
- pdm install -G doc --no-default
+ pdm install -G doc --no-default --no-self
- name: Build
run: |
From 22d6bf4d924827386ed119e79966fb687b9fff7c Mon Sep 17 00:00:00 2001
From: Starry-OvO
Date: Thu, 31 Aug 2023 11:33:27 +0800
Subject: [PATCH 11/11] chore: bump version to 3.7.2
---
aiotieba/__version__.py | 2 +-
aiotieba/const.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/aiotieba/__version__.py b/aiotieba/__version__.py
index f2eeedd6..3bdbbae2 100644
--- a/aiotieba/__version__.py
+++ b/aiotieba/__version__.py
@@ -1 +1 @@
-__version__ = "3.7.2a2"
+__version__ = "3.7.2"
diff --git a/aiotieba/const.py b/aiotieba/const.py
index 18328a66..9b8ad1d7 100644
--- a/aiotieba/const.py
+++ b/aiotieba/const.py
@@ -1,4 +1,4 @@
-MAIN_VERSION = "12.45.7.0"
+MAIN_VERSION = "12.46.3.0"
POST_VERSION = "12.35.1.0"
APP_SECURE_SCHEME = "https"