Catalog PyPI
Back to packageRELEASE DETAILS

1.0.1

PyPI

abara-file-io

This is a library that reads and writes Python local files in the most efficient way possible, without the need for detailed configuration.

Published13 Jun 2025
Direct dependencies3
Transitive dependenciesNot calculated

README

Version 1.0.1 documentation

Abara File IO

Description

Pythonのローカルファイルの読み書きを、細々とした設定なしに最適な方法で実行するライブラリ。

text、ini、json、yaml、tomlに対応。

読み込み時は自動的に文字コードを判定。
書き込み時は常に文字コード UTF-8 、改行コード \n を使用。

Dependency

tomli-w

ruamel.yaml

charset-normalizer

Install

pip

pip install abara-file-io

uv

uv add abara-file-io

Usage

ファイルの読み込み

ファイルを読み込む場合はread_から始まる関数を使用する。

from abara_file_io import read_text, read_ini, read_json, read_yaml, read_toml

path = './parent/stem.suffix'

text_response: str = read_text(path)

ini_response: dict = read_ini(path)

json_response: dict = read_json(path)

yaml_response: dict = read_yaml(path)

toml_response: dict = read_toml(path)

読み込みは第1引数にファイルのパス( str か、pathlibの Path オブジェクト)を指定するだけで動作する。

エンコードは最初に UTF-8 を試し、違った場合はcharset-normalizerで自動的に判定して読み込むので煩わされる必要がない。

読み込み時に存在しないファイルパスを指定などしてエラーが出た場合もエラーで停止しない仕様。
その場合は空の str もしくは dict を返すので、必要に応じて処理を分岐させることができる。

ファイルの書き込み

書き込む場合はwrite_から始まる関数を使用する。

from abara_file_io import write_text, write_ini, write_json, write_yaml, write_toml

path = './parent/stem.suffix'

str_data = 'Beautiful is better than ugly.'

dict_data = {'foo': 'bar', 'baz': 'qux'}

write_text(str_data, path)

write_ini(dict_data, path)

write_json(dict_data, path)

write_yaml(dict_data, path)

write_toml(dict_data, path)

書き込みは第1引数に書き込むオブジェクト。
第2引数に保存するファイル拡張子まで含めたパス( str か、pathlibの Path オブジェクト)を入れる。

常に文字コード UTF-8 、改行コード \n で保存されるのでWindowsで指定を忘れてしまうことがなく安全。
拡張子を .bat と .cmd にした場合のみ、 UTF-8 では動作しないため自動的にShift-JIS( CP932 )と \r\n で保存される。

書き込みに保存先パスの指定ミス等で処理が失敗してもエラーで停止しない仕様。
もし失敗時に何をさせたい場合、全ての関数は書き込みに成功したら True 、失敗したら False を返すので、必要に応じて処理を分岐させることができる。

Licence

MIT

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 3

Native requirements
3 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
charset-normalizer
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.12",
  "evaluation": "NOT_EVALUATED"
}
charset-normalizer>=3.4.2runtime
ruamel-yaml
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.12",
  "evaluation": "NOT_EVALUATED"
}
ruamel-yaml>=0.18.10runtime
tomli-w
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.12",
  "evaluation": "NOT_EVALUATED"
}
tomli-w>=1.2.0runtime

Distribution files

2 collected
abara_file_io-1.0.1-py3-none-any.whl

bdist_wheel · 10.96 KB · Python py3

Source file
abara_file_io-1.0.1.tar.gz

sdist · 14.08 KB · Python source

Source file

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 17:10 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:57f0d9f9fc628dca7dbb43c3b94ac6a90bedc8f010d0a1aa769cd6fe0a597bdf

Other collected versions

View all collected versions →