Skip to main content

simple-utils

일상적인 작업을 위한 간단한 파이썬 유틸리티 모음입니다.

설치 방법

pip install simple-utils

주요 기능

  • DateTime Utils: 날짜 및 시간 처리 유틸리티
  • String Utils: 문자열 처리 유틸리티
  • File Utils: 파일 및 경로 처리 유틸리티
  • Decorators: retry, timing 등 유용한 데코레이터
  • Object Storage: 파일 기반 객체 저장소

사용법

DateTime Utils

from simple_utils import datetime_utils

# 현재 타임스탬프 가져오기
ts = datetime_utils.now_timestamp()

# 날짜 문자열 파싱
dt = datetime_utils.parse_date("2024-01-15")

# datetime 포맷팅
formatted = datetime_utils.format_datetime(dt, "%Y/%m/%d")

# 날짜 범위 구하기
dates = datetime_utils.date_range("2024-01-01", "2024-01-07")

String Utils

from simple_utils import string_utils

# 케이스 변환
snake = string_utils.to_snake_case("HelloWorld")  # "hello_world"
camel = string_utils.to_camel_case("hello_world")  # "helloWorld"
pascal = string_utils.to_pascal_case("hello_world")  # "HelloWorld"

# 문자열 자르기
truncated = string_utils.truncate("Hello World", 8)  # "Hello..."

# 랜덤 문자열 생성
random_str = string_utils.random_string(10)

File Utils

from simple_utils import file_utils

# JSON 읽기/쓰기
data = file_utils.read_json("config.json")
file_utils.write_json("output.json", data)

# 디렉토리 생성 보장
file_utils.ensure_dir("/path/to/directory")

# 파일 확장자 얻기
ext = file_utils.get_extension("document.pdf")  # ".pdf"

Decorators

from simple_utils import decorators

# 재시도 데코레이터
@decorators.retry(max_attempts=3, delay=1.0)
def unstable_function():
    # 가끔 실패할 수 있음
    pass

# 실행 시간 측정 데코레이터
@decorators.timing
def slow_function():
    # 시간이 오래 걸리는 함수
    pass

# 결과 캐싱 데코레이터
@decorators.memoize
def expensive_calculation(x):
    return x ** 2

Object Storage

파일 기반의 간단한 객체 저장소로, 텍스트, JSON, 바이너리 데이터를 키 기반으로 저장/조회/삭제할 수 있습니다.

from simple_utils.storage import ObjectStorage

# 저장소 인스턴스 생성 (예: ./data 디렉토리)
storage = ObjectStorage("./data")

# 텍스트 저장 및 읽기
storage.write("hello.txt", "안녕하세요!")
print(storage.read_text("hello.txt"))  # '안녕하세요!'

# JSON 저장 및 읽기
storage.write("user.json", {"name": "홍길동", "age": 30})
user = storage.read("user.json")  # {'name': '홍길동', 'age': 30}

# 바이너리 데이터 저장 및 읽기
storage.write("image.bin", b"\x00\x01\x02")
data = storage.read_bytes("image.bin")

# 파일 존재 여부 확인
exists = storage.exists("user.json")

# 파일 삭제
storage.delete("hello.txt")

# 저장소 내 모든 파일(키) 목록 조회
all_keys = storage.list_keys()

# 특정 폴더 내 파일 목록 조회
sub_keys = storage.list_keys("images/")

# 하위 디렉토리 목록 조회
dirs = storage.list_dirs()

주요 메서드

  • write(key, data): 텍스트, JSON(dict/list), 바이너리(bytes) 저장
  • read(key): 텍스트 또는 JSON 자동 판별하여 읽기
  • read_text(key): 텍스트로 읽기
  • read_bytes(key): 바이너리로 읽기
  • delete(key): 파일 삭제
  • exists(key): 파일 존재 여부 확인
  • list_keys(prefix): (옵션) prefix로 시작하는 모든 파일 목록
  • list_dirs(): 하위 디렉토리 목록

라이선스

MIT License

Metadata

Release files for simple-utils 8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simple-utils 8
File Size Uploaded Provenance Actions
simple_utils-8.tar.gz 12.5 kB With provenance Details for simple_utils-8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for simple-utils 8
File Interpreter ABI Platform Actions
simple_utils-8-py3-none-any.whl Python 3 none any Details for simple_utils-8-py3-none-any.whl

Total release size: 26.6 kB

Release files / simple_utils-8.tar.gz

Download URL simple_utils-8.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a26fa063bba966262295a19b656eaba467848b53dfc698d60c201f77e95a00fe
BLAKE2b-256 checksum
How to use checksums
da68b34c0d3b83c3232a96aee1e04f54f422022a942a439f107f962dd37f33b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 3, 2026.

Transparency log

Release files / simple_utils-8-py3-none-any.whl

Download URL simple_utils-8-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b859d6e4772ae1f6edd2f2d89031440a50f2c5a7036cd893bbe120a5a7e7b17
BLAKE2b-256 checksum
How to use checksums
c718c4dc2ad30249304fd68b7452430c6f7686c201ef01d8c502c636871f3b85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 3, 2026.

Transparency log

Security for simple-utils 8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for simple_utils-8.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

8 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page