Problems including pyconfig

Asked by Jonathan Kossick on 2012-05-10

Hello, I have a problem I can't fix...
Since I added the pyconfig module to my application I get an error while packaging:

running build_i18n
error: voc2brain/configurations/pyconfig: Ist ein Verzeichnis
make: *** [debian/python-module-stampdir/voc2brain] Fehler 1
dpkg-buildpackage: Fehler: Fehler-Exitstatus von debian/rules build war 2

Translation for "Ist ein Verzeichnis": is a directory
Link to the pyconfig module:

I already added the pyconfig directory to "data_files" but the error occurs anyway...

Question information

English Edit question
Quickly Edit question
No assignee Edit question
Solved by:
Jonathan Kossick
Last query:
Last reply:
Tony Byrne (tony-badwolf) said : #1

Hi Jonathan
 I had a look at PyConfig and it made me sad. It's 3 year old code and there are better "included batteries" now. The actual fault is probably related to statements in PyConfig importing data_eval, the outer directory also being called PyConfig and the presence of

 I suppose everyone sooner or later everyone writes a pickle replacement, here is another one, includes a test.

# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-


Alternative for ConfigParser/shelve/pickle. Stores a dict as json object into a file.

:license: GNU GPL v3 or above.

import os
import json

class PyConfig(dict):
    def __init__(self, filename, verbose=1, *args, **kwds):
        self.filename = filename
        self.verbose = verbose

        dict.__init__(self, *args, **kwds)

        if os.path.isfile(self.filename):
            if self.verbose:
                print "PyConfig info: file '%s' doesn't exist, yet." % (

    def _read(self):
        if self.verbose:
            print "Reading %r ..." % self.filename

        f = file(self.filename, "r")
        data = json.load(f)

        dict.update(self, data)

    def save(self):
        if self.verbose:
            print "Save into %r ..." % self.filename,

        f = file(self.filename, "w")
        json.dump(self, f, sort_keys=True, indent=4)
        if self.verbose:
            print "OK, data saved."

if __name__ == '__main__':
    py = PyConfig(filename="FooBar.txt")
    py["foo"] = "bar"
    py[1] = "FooBar"

    py = PyConfig(filename="FooBar.txt")
    print py # should look like: {"foo": "bar, 1: "FooBar"}

    # however json silently coerces keys to strings :(
    assert py == {"foo": "bar", '1': "FooBar"}

Jonathan Kossick (j-kossick) said : #2

Thanks a lot! It worked for me but I had to integrate your code in my main and delete the pyconfig folder. Thanks a lot