Skip to content

Commit

Permalink
hooks: add hook for opencc-python (#627)
Browse files Browse the repository at this point in the history
  • Loading branch information
BLKSerene committed Aug 19, 2023
1 parent d0af799 commit f3756f6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/627.new.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add hook for ``opencc-python``.
1 change: 1 addition & 0 deletions requirements-test-libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ jsonschema==4.19.0
psutil==5.9.5
litestar==2.0.0rc1
lingua-language-detector==1.3.2; python_version >= '3.8'
opencc-python-reimplemented==0.1.7

# ------------------- Platform (OS) specifics

Expand Down
15 changes: 15 additions & 0 deletions src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-opencc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# ------------------------------------------------------------------
# Copyright (c) 2023 PyInstaller Development Team.
#
# This file is distributed under the terms of the GNU General Public
# License (version 2.0 or later).
#
# The full license is available in LICENSE.GPL.txt, distributed with
# this software.
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ------------------------------------------------------------------

from PyInstaller.utils.hooks import collect_data_files

datas = collect_data_files('opencc')
11 changes: 11 additions & 0 deletions src/_pyinstaller_hooks_contrib/tests/test_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1735,3 +1735,14 @@ def test_lingua_language_detector(pyi_builder):
assert detector.detect_language_of("languages are awesome") == Language.ENGLISH
""")


@importorskip('opencc')
def test_opencc(pyi_builder):
pyi_builder.test_source("""
import opencc
cc = opencc.OpenCC('s2t')
assert cc.convert('开放中文转换') == '開放中文轉換'
""")

0 comments on commit f3756f6

Please sign in to comment.