Git Product home page Git Product logo

configparser-1's Introduction

Configparser

This is a fork of https://github.com/alyu/configparser

The original libray focuses on parsing ini files into memory, and re-serializing to disk while preserving comments and whitespace. To achieve that, the in-memory has some quirks which most people probably don't want.

This fork breaks the writing config files functionality in order to get a more sensible config reading experience. That said, there are still plenty of quirks, making this only useful for a handful of carefully picked use cases.

You should probably not use this library

Known quirks and problems (mainly inherited from upstream):

  • Since values are unquoted strings, it is effectively impossibly to truly distinguish comments from values. We simply split keys from values at the first '=' and consider any "#" to mark a comment. Any other chars are allowed.
  • parsed values preserve file comments (but there's now an api to strip them. see below)
  • empty section names are legal.
  • section markers like [[[foo[][] are legal, though hard to reason about. (this one results in a section named foo[)
  • sections without any options are legal.
  • Any characters are allowed in section names
  • epmty lines result in options with empty names
  • Lines with nothing but comments result in "options" with the whole line (including comment delimiter) as name.

Most of these issues can, and should, be worked around in the caller by doing strict validation checking, based on your use case.

Main differences with upstream

  • parsed section names no longer include file comments
  • global section is kept separate so you can distinguish it from a section named "global".
  • stricter validation and parsing of section headers
  • add method to retrieve values without comments (ValueOfWithoutComments() )
  • add lots of unit tests (see extra_test.go)
  • only "=" is allowed as key-value delimiter (not ":" because our values may contain it)
  • only "#" is allowed to start comments (not ";" because our values may contain it)

configparser-1's People

Contributors

alyu avatar aozd4v avatar dieterbe avatar otterley avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.