zachperkitny / configparser Goto Github PK
View Code? Open in Web Editor NEWA NodeJS module based off of Python's ConfigParser. It implements a basic configuration file parser.
Home Page: https://zachperkitny.github.io/configparser/
A NodeJS module based off of Python's ConfigParser. It implements a basic configuration file parser.
Home Page: https://zachperkitny.github.io/configparser/
Consider the following
[REPLICA_SET]
additional_directories = ['${JSONAR_LOCALDIR}/credentials', '${JSONAR_DATADIR}/sonarfinder/reports']
This crashes the parser.
If I were to patch:
const SECTION = new RegExp(/^\s*\[([^\]]+)]$/);
to
const SECTION = new RegExp(/^\s*\[([^\]]+)]\s*$/);
this fixes the problem.
The parser fails when reading the following file:
[bumpversion]
current_version = 0.0.1
commit = True
tag = True
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(-a(?P<pmr>\d+)(\.dev(?P<build>\d+))?)?
serialize =
{major}.{minor}.{patch}-a{pmr}.dev{build}
{major}.{minor}.{patch}-a{pmr}
{major}.{minor}.{patch}
[bumpversion:file:setup.py]
[bumpversion:file:test/__init__.py]
[bumpversion:file:hpha_synchronization/__init__.py]
[bumpversion:file:hpha_synchronization/docs/__init__.py]
[bumpversion:file:hpha_synchronization/_internal/__init__.py]
on the lines following the serialize
key. The same file reads fine using the python https://docs.python.org/3/library/configparser.html package.
The current implementation (0.3.9) parses a file like
[sec]
key = [value]
as a config with two empty sections 'sec'
and 'value'
. The key 'key'
is lost all together.
Colons (:) are valid inside section headers. Please update regex to support colons.
In the line https://github.com/ZachPerkitny/configparser/blob/master/src/configparser.js#L265 and https://github.com/ZachPerkitny/configparser/blob/master/src/configparser.js#L258 you are reference the attribute file. The var is not defined and ends in exception if a parser error happens.
(node:8) UnhandledPromiseRejectionWarning: ReferenceError: file is not defined
at /app/node_modules/configparser/src/configparser.js:263:45
at Array.forEach (<anonymous>)
at ConfigParser.parseLines (/app/node_modules/configparser/src/configparser.js:248:11)
at ConfigParser.read (/app/node_modules/configparser/src/configparser.js:109:16)
at Startup (/app/src/index.js:12:10)
at Object.<anonymous> (/app/src/index.js:254:1)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
Let's assume we are in a folder with the path /home/development/codegenerator
and want to create a file called config.ini
in the folder /home/development/codegenerator/out/configuration/
and both of these folders are non existent. You'll receive an error because you need to create these folders by yourself.
I would suggest automatically creating these folders in future versions.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.