# pyconf

> Read and write python config files non-destructively (preserves comments)

Latest version **1.1.7** (published 2019-04-16) · (MIT OR Apache-2.0) license · 0 weekly downloads

## Install

```sh
npm install pyconf
pnpm add pyconf
yarn add pyconf
bun add pyconf
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.7 |
| Published | 2019-04-16 |
| First published | 2015-12-15 |
| Weekly downloads | 0 |
| License | (MIT OR Apache-2.0) |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 9.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | AJ ONeal |
| Maintainers | coolaj86 |
| Keywords | python, conf, config, comments |

## Links

- npm: https://www.npmjs.com/package/pyconf
- Repository: https://git.coolaj86.com/coolaj86/pyconf.js
- Homepage: https://git.coolaj86.com/coolaj86/pyconf.js#readme
- Issues: https://git.coolaj86.com/coolaj86/pyconf.js/issues
- npm.io page: https://npm.io/package/pyconf

## Dependencies (1)

- [safe-replace](https://npm.io/package/safe-replace.md) ^1.0.2

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.1.7 (latest) — 2019-04-16
- 1.1.6 — 2018-09-03
- 1.1.5 — 2018-05-13
- 1.1.2 — 2016-02-11
- 1.1.1 — 2016-02-11
- 1.1.0 — 2015-12-20
- 1.0.0 — 2015-12-15

## README

# pyconf.js
<small>formerly `node-config-python`</small>

Read and write python config files non-destructively (preserves comments and line-order)

Turns this kind of thing:

```python
foo = True
bar = None
baz = whatever
qux = apples,bananas
```

Into this kind of thing:

```javascript
{ foo: true
, bar: null
, baz: "whatever"
, qux: ["apples", "bananas"]
}
```

(comments are stored in meta-data keys `__lines` and `__keys`)

## Install

```bash
npm install --save pyconf
```

## Usage

```javascript
var pyconf = require('pyconf');

// alias for fs.readFile() then pyconf.parse()
pyconf.readFile("/path/to/foo.conf", function (err, obj) {
  console.log(obj);
});

// alias for pyconf.stringify() then safeReplace.writeFile()
pyconf.writeFile("/path/to/foo.conf", obj, function (err, obj) {
  console.log("wrote file");
});
```

Note: the `writeFile` function uses `safe-replace` so that it will work even in environments where race conditions are possible and will also create a backup file `whatever.conf.bak` of the config being overwritten.

## API

```javascript
pyconf
  .parse(str, cb)                   // => err, object

  .stringify(obj, cb)               // => err, text

  .readFile(filename, cb)           // => err, object

  .writeFile(filename, obj, cb)     // => err
```

---
_Source: https://npm.io/package/pyconf · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
