Python equivalence to org.apache.commons.configuration?

1.3k views Asked by At

I want to port this Configuration.class object (from http://pastebin.com/dZeV27XB) into python and it seems hard to port the org.apache.commons.configuration object

In the java class, there were multiple functions that returns a Configuration.getString or Configuration.getInt e.g.

  public int getDumpEndDir()
  {
    return this.config.getInt("wiki.dump.endDir");
  }

  public String getDocDir()
  {
    return this.config.getString("wiki.dump.docDir");
  }

Any clue to what such function return?

Is there a python library similar to org.apache.commons? Especially if there is one with the org.apache.commons.configuration library.

Is there a reason why this is in Java but not python?

1

There are 1 answers

0
AudioBubble On BEST ANSWER

You can use python's inbuild ConfigParser module which is very similar to Java's properties file loader. But here, the configuration parameters will be split section-wise. check this, https://docs.python.org/2/library/configparser.html

If it is an inmemory config structure, then you can simply use a dictionary object...