New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pyconf

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pyconf

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

  • 1.1.7
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
4.7K
increased by2.09%
Maintainers
1
Weekly downloads
 
Created
Source

pyconf.js

formerly node-config-python

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

Turns this kind of thing:

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

Into this kind of thing:

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

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

Install

npm install --save pyconf

Usage

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

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

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

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

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

Keywords

FAQs

Package last updated on 16 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc