simtoolsz 0.2.14__tar.gz → 0.2.14.2__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.
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/PKG-INFO +1 -1
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/pyproject.toml +1 -1
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/src/simtoolsz/__init__.py +1 -1
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/src/simtoolsz/reader.py +36 -4
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/.github/workflows/publish.yml +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/.github/workflows/test.yml +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/.gitignore +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/.python-version +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/LICENSE +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/README.md +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/README_EN.md +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/README_countrycode.md +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/README_countrycode_en.md +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/docs/DATETIME_CONVERSION.md +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/docs/iso3166-1.xlsx +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/docs/mail_usage_guide.md +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/docs/special2db_usage.md +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/examples/conversion_examples.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/examples/mail_examples.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/examples/special2db_example.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/examples/today_examples.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/examples/zip2db_example.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/requirements-dev.lock +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/requirements.lock +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/src/simtoolsz/columns_info +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/src/simtoolsz/country.parquet +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/src/simtoolsz/countrycode.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/src/simtoolsz/datetime.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/src/simtoolsz/db.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/src/simtoolsz/mail.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/src/simtoolsz/utils.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/tests/test_conversion.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/tests/test_countrycode.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/tests/test_countrycode_optimization.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/tests/test_iso_comprehensive.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/tests/test_iso_format.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/tests/test_optimized_reader.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/tests/test_simple.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/tests/test_smoke.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/tests/test_special2db.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/tests/test_special2db_simple.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/tests/test_today_optimized.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/tests/test_which_format.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/tests/test_zip2db.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/tests/test_zip2db_simple.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/tests/verify_unicode_fix.py +0 -0
- {simtoolsz-0.2.14 → simtoolsz-0.2.14.2}/uv.lock +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: simtoolsz
|
|
3
|
-
Version: 0.2.14
|
|
3
|
+
Version: 0.2.14.2
|
|
4
4
|
Summary: A simple and convenient toolkit containing useful functions, classes, and methods.
|
|
5
5
|
Project-URL: Homepage, https://github.com/SidneyLYZhang/simtoolsz
|
|
6
6
|
Project-URL: Repository, https://github.com/SidneyLYZhang/simtoolsz.git
|
|
@@ -25,7 +25,7 @@ import simtoolsz.countrycode as countrycode
|
|
|
25
25
|
try:
|
|
26
26
|
__version__ = importlib.metadata.version("simtoolsz")
|
|
27
27
|
except importlib.metadata.PackageNotFoundError:
|
|
28
|
-
__version__ = "0.2.14"
|
|
28
|
+
__version__ = "0.2.14.2"
|
|
29
29
|
|
|
30
30
|
__author__ = "Sidney Zhang <zly@lyzhang.me>"
|
|
31
31
|
|
|
@@ -715,7 +715,7 @@ def read_csv_advanced(
|
|
|
715
715
|
csv_content = "\n".join(data_lines)
|
|
716
716
|
|
|
717
717
|
return pl.read_csv(
|
|
718
|
-
io.BytesIO(csv_content.encode(
|
|
718
|
+
io.BytesIO(csv_content.encode("utf-8")),
|
|
719
719
|
**read_kwargs
|
|
720
720
|
)
|
|
721
721
|
|
|
@@ -752,11 +752,43 @@ def _read_from_zip_file(zip_path: Path, csv_name: Optional[str], encoding: str)
|
|
|
752
752
|
Returns:
|
|
753
753
|
str: CSV 文件的文本内容
|
|
754
754
|
"""
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
755
|
+
zf = _open_zip_with_encoding(zip_path)
|
|
756
|
+
try:
|
|
757
|
+
resolved_csv_name = _resolve_csv_name_zip(zf, csv_name, zip_path)
|
|
758
|
+
with zf.open(resolved_csv_name) as f:
|
|
758
759
|
actual_encoding = "utf-8-sig" if encoding == "utf-8" else encoding
|
|
759
760
|
return f.read().decode(actual_encoding)
|
|
761
|
+
finally:
|
|
762
|
+
zf.close()
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
def _open_zip_with_encoding(zip_path: Path) -> ZipFile:
|
|
766
|
+
"""
|
|
767
|
+
以正确的编码打开 ZIP 文件,解决中文文件名乱码问题。
|
|
768
|
+
|
|
769
|
+
优先尝试 GBK 编码(中文 Windows 常见),失败则使用默认编码。
|
|
770
|
+
|
|
771
|
+
Args:
|
|
772
|
+
zip_path: ZIP 文件路径
|
|
773
|
+
|
|
774
|
+
Returns:
|
|
775
|
+
ZipFile: 打开的 ZipFile 对象
|
|
776
|
+
"""
|
|
777
|
+
try:
|
|
778
|
+
zf = ZipFile(zip_path, "r", metadata_encoding="gbk")
|
|
779
|
+
zf.namelist()
|
|
780
|
+
return zf
|
|
781
|
+
except (UnicodeDecodeError, LookupError):
|
|
782
|
+
pass
|
|
783
|
+
|
|
784
|
+
try:
|
|
785
|
+
zf = ZipFile(zip_path, "r", metadata_encoding="cp936")
|
|
786
|
+
zf.namelist()
|
|
787
|
+
return zf
|
|
788
|
+
except (UnicodeDecodeError, LookupError):
|
|
789
|
+
pass
|
|
790
|
+
|
|
791
|
+
return ZipFile(zip_path, "r")
|
|
760
792
|
|
|
761
793
|
|
|
762
794
|
def _read_from_directory(dir_path: Path, csv_name: Optional[str], encoding: str) -> str:
|
|
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
|