--- id: charmlibs-pathops version: "1.3.0.post0" license: Apache-2.0 license_treatment: permissive maintenance: active --- # charmlibs-pathops — A pathlib-like interface for Juju K8s charms to interact with files in their workload container. License: permissive · Maintenance: active · Downloads: 80.3K/mo ## What it is and what it does charmlibs-pathops is a filesystem abstraction library for Juju Charms that unifies file operations across local charm containers and remote workload containers. It wraps the ops framework and provides LocalPath and ContainerPath classes that implement a common PathProtocol interface—a subset of pathlib.Path—allowing charm code to work with either filesystem using identical method calls. The library is designed for Kubernetes charms that need to read from or write to files in both the charm container and the workload container. It handles path operations like mkdir, read_bytes, write_text, and a helper ensure_contents function that idempotently sets file contents and reports whether changes were made. It does not support relative paths, the open method, or symlink/hardlink manipulation; mkdir, write_bytes, and write_text accept mode, user, and group parameters to set permissions and ownership directly. Use it for: - Copy configuration files from a charm container to a workload container with permission and ownership control. - Write charm-generated configuration to a workload container and detect whether the workload needs to reload. - Implement charm logic that works identically on both machine and Kubernetes charms by accepting a PathProtocol argument. - Ensure a file exists with specific content and ownership in a workload container, idempotently. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides a pathlib-like interface for reading and writing files in local filesystems and Juju workload container paths, supporting both Kubernetes and machine charms. Yes—if you are writing Juju Charms that need to interact with container filesystems. The library eliminates boilerplate for path handling and unifies the API across charm types. No known vulnerabilities, permissive license, low install friction, and active maintenance. Not relevant for non-charm Python projects. ## Install pip install charmlibs-pathops uv add charmlibs-pathops poetry add charmlibs-pathops ## Installing charmlibs-pathops Before you install: Low friction: pure Python wheel with a single runtime dependency (ops). Active maintenance with recent releases; last commit 2026-08-14. License in practice: Apache-2.0 permissive license allows commercial and private use with minimal restrictions. Quickstart: from charmlibs import pathops import ops class KubernetesCharm(ops.CharmBase): def __init__(self, framework: ops.Framework): super().__init__(framework) container = self.unit.get_container('container-name') self.root = pathops.ContainerPath('/', container=container) path = self.root / 'foo/bar' path.write_text('content') Requires Python >=3.10 and ops as a runtime dependency. Verify before relying: - Whether PathProtocol's subset of pathlib.Path API covers typical charm file-handling workflows beyond the documented examples. - Performance characteristics when working with large files or many operations across container boundaries. ## Package facts - License: Apache-2.0 (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 80.3K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags juju charm file operations, pathlib container paths, kubernetes charm filesystem, workload container file access, charm path abstraction, juju charm io, juju-charms, container-filesystem [View on SkillFed](https://skillfed.io/packages/charmlibs-pathops) · [View on PyPI](https://pypi.org/project/charmlibs-pathops/)