Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brain not defined? #15

Closed
Garanaw opened this issue Feb 22, 2017 · 4 comments
Closed

Brain not defined? #15

Garanaw opened this issue Feb 22, 2017 · 4 comments

Comments

@Garanaw
Copy link

Garanaw commented Feb 22, 2017

I'm not really sure if this is a bug or just happens to me. Im running it as a module having this structure:

  • main.py
  • programy/
  • test/

So calling (first of all) to test/test_config.XMLConfigurationFile(), I'm getting an error comming from the class BotConfiguration (defined in the same file, line 253), method load_config_section, saying that [NameError: name "brain" is not defined]. That variable is used in that method on line 267, and it took me a while to realize that is not exactly "just a name section", but an ElementTree what was supposed to be passed on that call. So, here's what I had to do to get it working (at least I'm not getting that error anymore) in case someone else needs it:

def load_config_section(self, config_file, bot_root):
    bot = config_file.get_section(self.section_name)
    if bot is not None:
        # commented this next line which was the one giving the error
        #self._supress_warnings = config_file.get_option("supress_warnings", brain)
        # and added the next one
        self._supress_warnings = config_file.get_option("supress_warnings", config_file.get_section("brain"))
        self._prompt = config_file.get_option("prompt", bot)
        self._default_response = config_file.get_option("default_response", bot)
        self._exit_response = config_file.get_option("exit_response", bot)
        self._initial_question = config_file.get_option("initial_question", bot)
    else:
        logging.warning("Config section [%s] missing", self.section_name)

I'm really new using python (first thing I've ever tried on this language), so we'll see if I can get it working, though some documentation would be very much appreciated. Anyways, thanks very much for building this AI

@keiffster
Copy link
Owner

Just back from a biz trip overseas, let me take a look and get back to you
Config needs more testing to handle areas which are missing from the file, this might be the case here

@keiffster
Copy link
Owner

Check out the new release 0.5.0 which has a rewritten pattern matching parser which is much better at topic and that handling

If you are still having problems, send me a copy of your config file and I'll debug it direct

@keiffster
Copy link
Owner

OK, I see your problem, it's because the code does not yet handle missing values as good as it could

I'll schedule to work on this area of the code soon. I've had a item on the backlog to add default values to all settings, so if you miss one, it uses the default value and writes a warning to the log file

K

@keiffster
Copy link
Owner

if you take the master head you will find that the whole section has been changed to support default values if appropriate or throw an exception and stop if not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants