{"id":15444529,"url":"https://github.com/cariad/py-wpconfigr","last_synced_at":"2025-04-19T20:25:58.086Z","repository":{"id":58785594,"uuid":"159678776","full_name":"cariad/py-wpconfigr","owner":"cariad","description":"A Python package for reading and writing configuration values in a WordPress wp-config.php file.","archived":false,"fork":false,"pushed_at":"2022-09-07T12:04:24.000Z","size":35,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T12:51:22.819Z","etag":null,"topics":["python","wordpress"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cariad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-29T14:28:46.000Z","updated_at":"2024-09-23T10:45:36.000Z","dependencies_parsed_at":"2022-09-08T09:20:08.247Z","dependency_job_id":null,"html_url":"https://github.com/cariad/py-wpconfigr","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cariad%2Fpy-wpconfigr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cariad%2Fpy-wpconfigr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cariad%2Fpy-wpconfigr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cariad%2Fpy-wpconfigr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cariad","download_url":"https://codeload.github.com/cariad/py-wpconfigr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249793667,"owners_count":21326570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","wordpress"],"created_at":"2024-10-01T19:41:36.971Z","updated_at":"2025-04-19T20:25:58.065Z","avatar_url":"https://github.com/cariad.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wpconfigger\n\n[![CircleCI](https://circleci.com/gh/cariad/py-wpconfigr/tree/master.svg?style=svg)](https://circleci.com/gh/cariad/py-wpconfigr/tree/master)\n\nA Python package for reading and writing configuration values in a WordPress `wp-config.php` file.\n\n## Overview\n\nA default `wp-config.php` might look like this:\n\n```php\n\u003c?php\ndefine( 'DB_NAME', 'database_name_here' );\n```\n\n`wpconfigger` will help you update the file to:\n\n```php\n\u003c?php\ndefine( 'SOMETHING_ENTIRELY_NEW', 'garnet' );\ndefine( 'DB_NAME', 'my_blog' );\n```\n\n`wpconfigger` exposes two functions:\n\n- `set(key, value)` will update a property of name `key` if it exists, otherwise will create it.\n- `get(key)` will return the value of the property of name `key`, or `None` if it doesn't exist.\n\n\n## Installation\n\n```shell\npip install wpconfigger\n```\n\n## Command-line usage\n\n### Writing values to wp-config.php\n\nNamed parameters:\n\n- `--filename`: Full path and filename of the `wp-config.php` file.\n- `--key`: Name of the property to create/update.\n- `--value`: String value to set.\n- `--set-true`: Set the value to boolean `true`.\n- `--set-false`: Set the value to boolean `false`.\n- `--log-level`: (Optional) Log level.\n\n```shell\npython -m wpconfigger --filename  /www/wp-config.php \\\n                      --key       DB_NAME \\\n                      --value     my_blog \\\n                      --log-level info\n```\n\n### Reading values from wp-config.php\n\nAs above, but do not specify a value (via the `--value`, `--set-true` or `--set-false` arguments).\n\n```shell\npython -m wpconfigger --filename /www/wp-config.php \\\n                      --key      DB_NAME\n```\n\n### Code usage\n\nTo update a string holding `wp-config.php` content:\n\n```python\nfrom wpconfigr import WpConfigString\n\nconfig = WpConfigString(config_string)\nconfig.set('DB_NAME', 'my_blog')\nupdated_config_string = config.content\n```\n\nTo directly update a `wp-config.php` file:\n\n```python\nfrom wpconfigger import WpConfigFile\n\nconfig = WpConfigFile(filename)\nconfig.set('DB_NAME', 'my_blog')\n# File is updated immediately after each property update.\n```\n\nTo read a property value:\n\n```python\ndb_name = config.get('DB_NAME')\n```\n\n## Development\n\n### Prerequisites\n\n`wpconfigger` requires Python 3.x.\n\n### Installing dependencies\n\n```shell\npip install -e .[dev]\n```\n\n### Running tests\n\n```shell\npython test.py\n```\n\n## Changelog\n\n### v1.0.0 - 2022-07-09\n\n- Renamed and republished as `wpconfigger`.\n\n### v1.4 - 2018-12-06\n\n- Fixed bug where commented properties were read and updated.\n\n### v1.3 - 2018-12-02\n\n- Added `--set-true` and `--set-false` command-line flags.\n\n### v1.2 - 2018-12-02\n\n- No longer re-writes the configuration file if nothing has changed.\n\n### v1.1 - 2018-12-02\n\n- Added logging.\n  - Test runs log everything.\n  - Running from the command-line logs only `CRITICAL` by default, but can be overridden with the new optional `--log-level` argument.\n- Made the documentation a little clearer, and fixed a typo in a code sample.\n- Replaced internal naming references to `FRACTIONAL` with `FLOAT`. The word utterly eluded me for v1.0.\n- Fixed some code formatting and Pylint warnings.\n- Ignore `coverage` HTML reports in source control.\n\n### v1.0 - 2018-12-01\n\n- Initial release.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcariad%2Fpy-wpconfigr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcariad%2Fpy-wpconfigr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcariad%2Fpy-wpconfigr/lists"}