# dockerfile-parse
[![unittests status badge]][unittests status link]
[![coveralls status badge]][coveralls status link]
[![lgtm python badge]][lgtm python link]
[![lgtm alerts badge]][lgtm alerts link]
[![linters status badge]][linters status link]
Python library for parsing Dockerfile files.
## Installation
### From PyPI
```shell
pip install dockerfile-parse
```
### From git
Clone this git repo and install using the python installer
```shell
git clone https://github.com/containerbuildsystem/dockerfile-parse.git
cd dockerfile-parse
sudo pip install .
```
## Usage
```python
from pprint import pprint
from dockerfile_parse import DockerfileParser
dfp = DockerfileParser()
dfp.content = """\
From base
LABEL foo="bar baz"
USER me"""
# Print the parsed structure:
pprint(dfp.structure)
pprint(dfp.json)
pprint(dfp.labels)
# Set a new base:
dfp.baseimage = 'centos:7'
# Print the new Dockerfile with an updated FROM line:
print(dfp.content)
```
[coveralls status badge]: https://coveralls.io/repos/containerbuildsystem/dockerfile-parse/badge.svg?branch=master
[coveralls status link]: https://coveralls.io/r/containerbuildsystem/dockerfile-parse?branch=master
[lgtm python badge]: https://img.shields.io/lgtm/grade/python/g/containerbuildsystem/dockerfile-parse.svg?logo=lgtm&logoWidth=18
[lgtm python link]: https://lgtm.com/projects/g/containerbuildsystem/dockerfile-parse/context:python
[lgtm alerts badge]: https://img.shields.io/lgtm/alerts/g/containerbuildsystem/dockerfile-parse.svg?logo=lgtm&logoWidth=18
[lgtm alerts link]: https://lgtm.com/projects/g/containerbuildsystem/dockerfile-parse/alerts
[linters status badge]: https://github.com/containerbuildsystem/dockerfile-parse/workflows/Linters/badge.svg?branch=master&event=push
[linters status link]: https://github.com/containerbuildsystem/dockerfile-parse/actions?query=event%3Apush+branch%3Amaster+workflow%3A%22Linters%22
[unittests status badge]: https://github.com/containerbuildsystem/dockerfile-parse/workflows/Unittests/badge.svg?branch=master&event=push
[unittests status link]: https://github.com/containerbuildsystem/dockerfile-parse/actions?query=event%3Apush+branch%3Amaster+workflow%3A%22Unittests%22
Raw data
{
"_id": null,
"home_page": "https://github.com/containerbuildsystem/dockerfile-parse",
"name": "dockerfile-parse",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "",
"author": "Jiri Popelka",
"author_email": "jpopelka@redhat.com",
"download_url": "https://files.pythonhosted.org/packages/92/df/929ee0b5d2c8bd8d713c45e71b94ab57c7e11e322130724d54f469b2cd48/dockerfile-parse-2.0.1.tar.gz",
"platform": null,
"description": "# dockerfile-parse\n\n[![unittests status badge]][unittests status link]\n[![coveralls status badge]][coveralls status link]\n[![lgtm python badge]][lgtm python link]\n[![lgtm alerts badge]][lgtm alerts link]\n[![linters status badge]][linters status link]\n\nPython library for parsing Dockerfile files.\n\n## Installation\n\n### From PyPI\n\n```shell\npip install dockerfile-parse\n```\n\n### From git\n\nClone this git repo and install using the python installer\n\n```shell\ngit clone https://github.com/containerbuildsystem/dockerfile-parse.git\ncd dockerfile-parse\nsudo pip install .\n```\n\n## Usage\n\n```python\nfrom pprint import pprint\nfrom dockerfile_parse import DockerfileParser\n\ndfp = DockerfileParser()\ndfp.content = \"\"\"\\\nFrom base\nLABEL foo=\"bar baz\"\nUSER me\"\"\"\n\n# Print the parsed structure:\npprint(dfp.structure)\npprint(dfp.json)\npprint(dfp.labels)\n\n# Set a new base:\ndfp.baseimage = 'centos:7'\n\n# Print the new Dockerfile with an updated FROM line:\nprint(dfp.content)\n```\n\n[coveralls status badge]: https://coveralls.io/repos/containerbuildsystem/dockerfile-parse/badge.svg?branch=master\n[coveralls status link]: https://coveralls.io/r/containerbuildsystem/dockerfile-parse?branch=master\n[lgtm python badge]: https://img.shields.io/lgtm/grade/python/g/containerbuildsystem/dockerfile-parse.svg?logo=lgtm&logoWidth=18\n[lgtm python link]: https://lgtm.com/projects/g/containerbuildsystem/dockerfile-parse/context:python\n[lgtm alerts badge]: https://img.shields.io/lgtm/alerts/g/containerbuildsystem/dockerfile-parse.svg?logo=lgtm&logoWidth=18\n[lgtm alerts link]: https://lgtm.com/projects/g/containerbuildsystem/dockerfile-parse/alerts\n[linters status badge]: https://github.com/containerbuildsystem/dockerfile-parse/workflows/Linters/badge.svg?branch=master&event=push\n[linters status link]: https://github.com/containerbuildsystem/dockerfile-parse/actions?query=event%3Apush+branch%3Amaster+workflow%3A%22Linters%22\n[unittests status badge]: https://github.com/containerbuildsystem/dockerfile-parse/workflows/Unittests/badge.svg?branch=master&event=push\n[unittests status link]: https://github.com/containerbuildsystem/dockerfile-parse/actions?query=event%3Apush+branch%3Amaster+workflow%3A%22Unittests%22\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "Python library for Dockerfile manipulation",
"version": "2.0.1",
"project_urls": {
"Homepage": "https://github.com/containerbuildsystem/dockerfile-parse"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7a6c79cd5bc1b880d8c1a9a5550aa8dacd57353fa3bb2457227e1fb47383eb49",
"md5": "a122cf2b57885afcab9451dccace8cf9",
"sha256": "bdffd126d2eb26acf1066acb54cb2e336682e1d72b974a40894fac76a4df17f6"
},
"downloads": -1,
"filename": "dockerfile_parse-2.0.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "a122cf2b57885afcab9451dccace8cf9",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.6",
"size": 14845,
"upload_time": "2023-07-18T13:36:06",
"upload_time_iso_8601": "2023-07-18T13:36:06.052681Z",
"url": "https://files.pythonhosted.org/packages/7a/6c/79cd5bc1b880d8c1a9a5550aa8dacd57353fa3bb2457227e1fb47383eb49/dockerfile_parse-2.0.1-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "92df929ee0b5d2c8bd8d713c45e71b94ab57c7e11e322130724d54f469b2cd48",
"md5": "323d2d89cca3ed346b0204fd00562a0d",
"sha256": "3184ccdc513221983e503ac00e1aa504a2aa8f84e5de673c46b0b6eee99ec7bc"
},
"downloads": -1,
"filename": "dockerfile-parse-2.0.1.tar.gz",
"has_sig": false,
"md5_digest": "323d2d89cca3ed346b0204fd00562a0d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 24556,
"upload_time": "2023-07-18T13:36:07",
"upload_time_iso_8601": "2023-07-18T13:36:07.897676Z",
"url": "https://files.pythonhosted.org/packages/92/df/929ee0b5d2c8bd8d713c45e71b94ab57c7e11e322130724d54f469b2cd48/dockerfile-parse-2.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-18 13:36:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "containerbuildsystem",
"github_project": "dockerfile-parse",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "dockerfile-parse"
}