Skip to main content

汎用ユーティリティ(ファイル操作、ログ出力など)

Project description

playground_common_utils

Pythonで汎用的なファイル操作・ディレクトリ操作・ログ出力を支援するライブラリです。


🚀 インストール

インストールするには:

pip install playground-common-utils

📦 主な機能

確認系

  • is_exist(path) : パスの存在確認
  • is_file(path) : ファイルか確認
  • is_dir(path) : ディレクトリか確認
  • is_match_first_keyword(target, first_keyword) : 文字列の最初のキーワードが一致しているか
  • is_match_last_keyword(target, last_keyword) : 文字列の最後のキーワードが一致しているか

作成系

  • create_file(path) : 空ファイル作成
  • create_dir(path) : ディレクトリ作成

取得系

  • read_current_dir() : カレントディレクトリ取得
  • read_file(path) : ファイル内容取得
  • read_list_dir(path) : ディレクトリ内一覧取得

更新系

  • overwrite_file(path, content) : ファイルに上書き
  • append_file(path, content) : ファイルに追記

削除系

  • delete_file(path) : ファイル削除
  • delete_dir(path) : ディレクトリ削除

操作系

  • copy_file(src_path, dst_path) : ファイルコピー
  • move_file(src_path, dst_path) : ファイル移動

ログ出力系

logger.debug("Debug test") : デバッグ ログ出力 logger.info("Debug test") : インフォ ログ出力 logger.worning("Debug test") : ワーニング ログ出力 logger.error("Debug test") : エラー ログ出力 logger.critical("Debug test") : クリティカル ログ出力

logger.set_level(WARNING) : Warning以上のログ出力可能 / DEBUG,INFOログは出力しない

🛠️ 使用例

ファイル作成書き込み削除
from playground_common_utils.files import *

# ファイル作成
create_file('sample.txt')

# ファイル上書き
overwrite_file('sample.txt', 'Hello World')

# ファイル削除
delete_file('sample.txt')

ディレクトリ操作

from playground_common_utils.files import *

# ディレクトリ作成
create_dir('new_folder')

# ディレクトリ内一覧取得
items = read_list_dir('new_folder')

# ディレクトリ削除
delete_dir('new_folder')

ログ出力

from playground_common_utils.logger import logger
logger.debug("Debug test")
# 🐞 2025-05-20 21:45:19 [DEBUG] | <stdin> / <module>  [1] | Debug test

logger.info("Info test")
# ℹ️  2025-05-20 21:45:33 [INFO] | <stdin> / <module>  [2] | Info test

logger.warning("Warning test")
# ⚠️  2025-05-20 21:45:40 [WARNING] | <stdin> / <module>  [3] | Warning test

logger.error("Error test")
# 🚨 2025-05-20 21:45:51 [ERROR] | <stdin> / <module>  [4] | Error test

logger.critical("Critical test")
# 🔥 2025-05-20 21:45:58 [CRITICAL] | <stdin> / <module>  [5] | Critical test

HTTP通信

from playground_common_utils.logger import http, HTTP_Method

response = fetch(url="http://example.com", # Endpoint URL
      method=HTTP_Method.GET, # GET / POST / PUT / DELETE
      request_headers={"Content-Type": "application/json"}, # Default = {"Content-Type": "application/json"}
      request_dict={}) # python dict型 ⚠️ 内部的にjsonに変換しリクエスト送信します

⚙️ 対応バージョン

  • Python 3.7以上

📄 ライセンス

MITライセンス

👤 作者情報

Author: Hiroki Umatani Project URL: Github

playground-common-utilsは、実業務に直結するファイル管理作業の効率化を目指して開発されました。 営業・開発・レポート作成などのプロジェクトを圧倒的スピードで推進するための基盤ライブラリです。

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

playground-common-utils-1.4.2.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

playground_common_utils-1.4.2-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file playground-common-utils-1.4.2.tar.gz.

File metadata

  • Download URL: playground-common-utils-1.4.2.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for playground-common-utils-1.4.2.tar.gz
Algorithm Hash digest
SHA256 73d986e77ded312081dd4a2218f13e008372b87d6678537f0e9b081642fb5c26
MD5 1dbe7967f634c2c5df68fa816f53c7ad
BLAKE2b-256 7bcccbbc818d68b98d1c64ef392d30920c53da84415997c0e08a2157f02f1ae2

See more details on using hashes here.

File details

Details for the file playground_common_utils-1.4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for playground_common_utils-1.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4e14440753ad860ae09a765f6a887c7f91e572ba3a37a497dbfded6be3ce2deb
MD5 b6367ef4fd307fbbb51c37c300491647
BLAKE2b-256 2dff385f5c6c325614660139af90e9228ba4f31fe187df432e91bff4b1038c90

See more details on using hashes here.

Supported by

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