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 7

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 7
File Size Uploaded Provenance Actions
simple_utils-7.tar.gz 11.9 kB With provenance Details for simple_utils-7.tar.gz

Built distribution (wheel)

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

Total release size: 26.0 kB

Release files / simple_utils-7.tar.gz

Download URL simple_utils-7.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1157bb0c4fd7a6ccf581b68ba57656254d429a793546293e034d7173a3f55361
BLAKE2b-256 checksum
How to use checksums
c3c5bbc9e1dac590b51e08da5234c166d3ae14badb3f5cea3ac3d6c4e815a50d
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-7-py3-none-any.whl

Download URL simple_utils-7-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e322c0c22d38b89321279b102d9b32d61c44e98659ef5f52ac502b495ab2557d
BLAKE2b-256 checksum
How to use checksums
76ac30f7d07f86ab8b5c6914894092286358628fecb06f71ea95a684db4c855a
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 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.

Full provenance

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

Select from 2 files

Attestation for simple_utils-7.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

7 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