{"library":"plette","title":"Plette","description":"Plette is a Python library that provides structured models for parsing, generating, and validating Pipfile and Pipfile.lock files. It allows developers to programmatically interact with project dependencies in a structured manner. The current version is 2.1.0, and it maintains a regular release cadence with significant updates, including a major version bump from v1 to v2.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install plette"],"cli":null},"imports":["from plette import Pipfile","from plette import Lockfile"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import io\nfrom plette import Pipfile, Lockfile\n\n# Example Pipfile content\npipfile_content = '''\n[[source]]\nurl = \"https://pypi.org/simple\"\nverify_ssl = true\nname = \"pypi\"\n\n[packages]\nrequests = \"*\"\n\n[dev-packages]\npytest = \"*\"\n\n[requires]\npython_version = \"3.8\"\n'''\n\n# Example Pipfile.lock content (simplified for demonstration)\nlockfile_content = '''\n{\n    \"_meta\": {\n        \"hash\": {\n            \"sha256\": \"some_hash\"\n        },\n        \"requires\": {\n            \"python_version\": \"3.8\"\n        }\n    },\n    \"default\": {\n        \"requests\": {\n            \"hashes\": [\n                \"sha256:hash1\",\n                \"sha256:hash2\"\n            ],\n            \"version\": \"==2.28.1\"\n        }\n    },\n    \"develop\": {\n        \"pytest\": {\n            \"hashes\": [\n                \"sha256:hash3\",\n                \"sha256:hash4\"\n            ],\n            \"version\": \"==7.1.2\"\n        }\n    }\n}\n'''\n\n# Load Pipfile\nwith io.StringIO(pipfile_content) as f:\n    pipfile = Pipfile.load(f)\n\nprint(f\"Pipfile Python Version: {pipfile.requires.python_version}\")\nprint(f\"Pipfile Packages: {list(pipfile.packages.keys())}\")\n\n# Load Lockfile\nwith io.StringIO(lockfile_content) as f:\n    lockfile = Lockfile.load(f)\n\nprint(f\"Lockfile requests version: {lockfile.default['requests']['version']}\")\nprint(f\"Lockfile meta hash: {lockfile._meta['hash']['sha256']}\")\n\n# Modify and dump (Pipfile example)\npipfile.packages['rich'] = '==12.0.0'\nwith io.StringIO() as f:\n    pipfile.dump(f)\n    print(\"\\nModified Pipfile content:\")\n    print(f.getvalue())\n","lang":"python","description":"This quickstart demonstrates how to load Pipfile and Pipfile.lock content from strings using `io.StringIO`, access their structured properties, and then modify and dump a Pipfile back to a string. It shows how to retrieve the required Python version from Pipfile, list packages, and access specific dependency versions from Lockfile.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}