`pathlib` Wrapper with **UTF-8 first** and **LineFeed first**, based on `pathlib3x`.
Project description
IceSpringPathLib
pathlib
Wrapper with UTF-8 first and LineFeed first, based on pathlib3x
.
Official sites
- Home: https://baijifeilong.github.io/2022/01/08/ice-spring-path-lib/index.html
- Github: https://github.com/baijifeilong/IceSpringPathLib
- PyPI(IceSpringPathLib): https://pypi.org/project/IceSpringPathLib
- PyPI(pathlib3x): https://pypi.org/project/pathlib3x
Features
UTF-8
is the default encoding, even onWindows
LineFeed
is the default new-line format, even onWindows
- All
pathlib3x
features
Install
- PyPI:
pip install IceSpringPathLib
Usage
import pathlib
import tempfile
import chardet
import IceSpringPathLib
tempfile.mktemp()
filename = tempfile.mktemp()
text = "Common\n常\nSense\n识\n天地玄黄"
print("Original text:", repr(text))
pathlib.Path(filename).write_text(text)
encoding = chardet.detect(open(filename, mode="rb").read())["encoding"]
print("\nWritten text by pathlib:", repr(open(filename, newline="", encoding=encoding).read()))
print("Written encoding by pathlib:", encoding)
IceSpringPathLib.Path(filename).write_text(text)
encoding = chardet.detect(open(filename, mode="rb").read())["encoding"]
print("\nWritten text by IceSpringPathLib:", repr(open(filename, newline="", encoding=encoding).read()))
print("Written encoding by IceSpringPathLib:", encoding)
Example Output
Original text: 'Common\n常\nSense\n识\n天地玄黄'
Written text by pathlib: 'Common\r\n常\r\nSense\r\n识\r\n天地玄黄'
Written encoding by pathlib: GB2312
Written text by IceSpringPathLib: 'Common\n常\nSense\n识\n天地玄黄'
Written encoding by IceSpringPathLib: utf-8
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
IceSpringPathLib-1.0.0.tar.gz
(18.2 kB
view details)
Built Distribution
File details
Details for the file IceSpringPathLib-1.0.0.tar.gz
.
File metadata
- Download URL: IceSpringPathLib-1.0.0.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 563294bb4f11ed2466f7b762cff782b472db57c23ee8774a684c6405a95ae7b6 |
|
MD5 | ea2fea6ded2f51cf5399d1ba01e2aa7c |
|
BLAKE2b-256 | 23d13d645ea1cf6625fc65f0031281095e7852a245188e11f82597a7b4af5513 |
File details
Details for the file IceSpringPathLib-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: IceSpringPathLib-1.0.0-py3-none-any.whl
- Upload date:
- Size: 21.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27feca420fd82e349e2509293ced281b73cbfc633630c3a92439588706b20cda |
|
MD5 | bdc3b40f960b8402054944ba893d1781 |
|
BLAKE2b-256 | a6424b326dc1df48d06acb475515396c7021743ba25ef2314922ba76af3811c4 |