1
0
mirror of https://github.com/gryf/gryf-overlay.git synced 2025-12-18 20:10:22 +01:00

Added patched version of pystardict lib

This commit is contained in:
2023-05-31 15:27:21 +02:00
parent 9fac88fa2e
commit e90a340277
4 changed files with 99 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
AUX pystardict-0.8-multiple-defs.patch 1894 BLAKE2B 28fd04194c97f70ca8a5fedf04cd4d13895699dfb90047142f855bc79d0ad1ac5e76365c5a3724a80558646e461b863f4c7eb622325ce7283e5e06bf585b0385 SHA512 99eeea5b8a45c1038c8a62e7cbdab4ddeb1b7302ec2035cf7987d629548325f85f3291dda8adca3a121cc2fec7cd9a017506e50844214ed67d522849d82b5add
DIST pystardict-0.8-r1.tar.gz 795302 BLAKE2B eed78612e616a56920ab40035dd14682d8420d34919df8f00deabdf36b287723cd12815cda9bb3c5eb9d6d123edd961dbd5da7301a4f5c5ac56b0b49665a5050 SHA512 a5cb64993e4d870c3fb30e78462ac52bba994088b51d74e2eb7a0c41436bd1bb6733c6a11f30404eae446669209a7dc8f8d74efb28f5cce3997c26fcad833db7
EBUILD pystardict-0.8-r10.ebuild 749 BLAKE2B 25737a166b3c48f684095d4377288e37eb30c5de57410ae8776465a596a78887a0970a70b7359b0fec39298ee2f758641eb58b93891cdb3a17b7bcb37c2ddebb SHA512 c4a69db98abe9d0da00487a60fd849addab7021b94473f34395b9ca8c24a4d4522ce983cf6011890768cc064585fed1ebbbc0e3c56547a408666184333b64712
MISC metadata.xml 367 BLAKE2B 4c982ca2fdd6a44557ff823473dc88fe20c0925547638be69beca6243502b7b60df5dca55d5ac1b008c212a6461c1ed7801a0d2d34d497b290fda58c545e1caa SHA512 989c991d08be58711ff075bdea9b815283cb79176cb3889a1cd2b46324478301d1c193cf0d07effb20d092c17414530bb9a0366c0c3167f3f67f853f0076a067

View File

@@ -0,0 +1,56 @@
--- a/pystardict.py
+++ b/pystardict.py
@@ -1,3 +1,4 @@
+from collections import defaultdict
import gzip
import hashlib
import os
@@ -142,7 +143,7 @@ class _StarDictIdx(object):
file.close()
""" prepare main dict and parsing parameters """
- self._idx = {}
+ self._idx = defaultdict(list)
idx_offset_bytes_size = int(container.ifo.idxoffsetbits / 8)
idx_offset_format = {4: 'L', 8: 'Q', }[idx_offset_bytes_size]
idx_cords_bytes_size = idx_offset_bytes_size + 4
@@ -164,7 +165,7 @@ class _StarDictIdx(object):
record_tuple = unpack(
'!%sc%sL' % (c + 1, idx_offset_format), matched_record)
word, cords = record_tuple[:c], record_tuple[c + 1:]
- self._idx[b''.join(word)] = cords
+ self._idx[b''.join(word)].append(cords)
def __getitem__(self, word):
"""
@@ -382,13 +383,16 @@ class _StarDictDict(object):
cords = self._container.idx[word]
if self._in_memory:
- bytes_ = self._file[cords[0]: cords[0] + cords[1]]
+ bytes_ = b'\n\n'.join([self._file[c[0]: c[0] + c[1]]
+ for c in cords])
else:
# seeking in file for data
- self._file.seek(cords[0])
+ def _read(cord):
+ self._file.seek(cord[0])
+ return self._file.read(cord[1])
# reading data
- bytes_ = self._file.read(cords[1])
+ bytes_ = b'\n\n'.join([_read(c) for c in cords])
return bytes_.decode('utf-8')
--- a/tests/test_pystardict.py
+++ b/tests/test_pystardict.py
@@ -33,7 +33,7 @@ def fixture_in_memory_dict():
def test001Idx(fixture_dict):
- assert fixture_dict.idx['test'] == (581161, 16,)
+ assert fixture_dict.idx['test'] == [(581161, 16,)]
def test002Dict(fixture_dict):

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<upstream>
<remote-id type="pypi">PyStarDict</remote-id>
<remote-id type="github">lig/pystardict</remote-id>
</upstream>
<maintainer type="person">
<email>1over137@anche.no</email>
<name>shaoyu</name>
</maintainer>
</pkgmetadata>

View File

@@ -0,0 +1,27 @@
# Copyright 2021-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{11..12} pypy3 )
DISTUTILS_USE_PEP517=setuptools
inherit distutils-r1 pypi
MY_PN="PyStarDict"
DESCRIPTION="Library for manipulating StarDict dictionaries from within Python"
HOMEPAGE="
https://pypi.org/project/PyStarDict/
https://github.com/lig/pystardict
"
SRC_URI="$(pypi_sdist_url --no-normalize ${MY_PN}) -> ${P}-r1.tar.gz"
S="${WORKDIR}/${MY_PN}-${PV}"
LICENSE="GPL-3"
SLOT="0"
KEYWORDS="~amd64 ~arm ~arm64 ~x86"
RDEPEND="dev-python/six[${PYTHON_USEDEP}]"
BDEPEND="dev-python/setuptools-scm[${PYTHON_USEDEP}]"
PATCHES=( "${FILESDIR}/pystardict-0.8-multiple-defs.patch" )
distutils_enable_tests pytest