Giter Site home page Giter Site logo

Comments (1)

dtext avatar dtext commented on June 10, 2024

After looking at this for a while, there doesn't seem to be very much we can do if we keep using configparser. I'd change a few smaller things:

  • Remove logging from config.py:
    This gets rid of the bug where we get an error message when there is no config file because of logging not being initialized when the default config is loaded. Doesn't really make any sense to log that info anyway, I think.

  • Handle parsing errors:
    At the moment, instantshare just dies with an exception when there are parsing errors. We should make the config parser more resilient and show the user what's wrong with the file and why we can't continue. ConfigParser itself raises some useful exceptions. We could re-raise them and handle them somewhere else or handle them in config.py. However, the latter is difficult because we need to decide how to give feedback to the user.

  • Put everything at module level:
    I don't think it's too bad to have a singleton here, but we should make all the functionality accessible via config instead of config.CONFIG if we're going to keep it this way, in order to hide the implementation details inside the module. This makes using the class a bit nicer.

Alternative
An alternative would be to replace configparser with something more flexible and modern like PyYAML, which can parse YAML strings and convert them to basic python types directly (dict, list, int, str, ...). I have used YAML in a few projects now and I like it a lot.

from instantshare.

Related Issues (20)

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.