def load(self, filename, replace = False):
import os, json, re<EOL>if os.path.exists(filename):<EOL><INDENT>f = open(filename, '<STR_LIT:r>')<EOL>content = f.read()<EOL>content = re.sub('<STR_LIT>', '<STR_LIT>', content)<EOL>try:<EOL><INDENT>settings = json.loads(content)<EOL><DEDENT>except ValueError:<EOL><INDENT>from lltk.exceptions import ConfigurationError<EOL>raise ConfigurationError('<STR_LIT>' + filename + '<STR_LIT>')<EOL><DEDENT>f.close()<EOL>if replace:<EOL><INDENT>self.settings = settings<EOL><DEDENT>else:<EOL><INDENT>self.settings.update(settings)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>lltkfilename = self.settings['<STR_LIT>'] + '<STR_LIT:/>' + self.settings['<STR_LIT>'] + filename<EOL>if os.path.exists(lltkfilename):<EOL><INDENT>return self.load(lltkfilename)<EOL><DEDENT>from lltk.exceptions import ConfigurationError<EOL>raise ConfigurationError('<STR_LIT>' + filename + '<STR_LIT>')<EOL><DEDENT>
Loads a configuration file (JSON).