Skip to main content

`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

Features

  • UTF-8 is the default encoding, even on Windows
  • LineFeed is the default new-line format, even on Windows
  • 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


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.1.0.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

IceSpringPathLib-1.1.0-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file IceSpringPathLib-1.1.0.tar.gz.

File metadata

  • Download URL: IceSpringPathLib-1.1.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

Hashes for IceSpringPathLib-1.1.0.tar.gz
Algorithm Hash digest
SHA256 e17442e93d8bb175db67954a897854d4f4287c584c496e25b8c746ccf0dace6a
MD5 718f0e4a46d265a682db3a5c3939910d
BLAKE2b-256 01fc2301ed66ac68b77951decf1751355748ca28e4614e8d0b0667872c93014f

See more details on using hashes here.

File details

Details for the file IceSpringPathLib-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: IceSpringPathLib-1.1.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

Hashes for IceSpringPathLib-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4715f6b740d114c5c1c8ee2332953b105a95ad1f589cb1b38be22493150df053
MD5 0d31bdb36ebe6978f070412d958150a2
BLAKE2b-256 1e75dce5aa44657d76ca20168ca728ca89bb2c0824f35cea60294ab7dbf5f147

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page