1
votes

The code posted here, I tried to compile the program but everytime I do it goves me this traceback:

Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/ceradon/cerabot-rewrite/cerabot/tasks/date_templates.py", line 187, in 
    bot = DateTemplates()
  File "/home/ceradon/cerabot-rewrite/cerabot/tasks/date_templates.py", line 19, in __init__
    super(DateTemplates, self).__init__()
  File "cerabot/bot.py", line 51, in __init__
    self.setup()
  File "/home/ceradon/cerabot-rewrite/cerabot/tasks/date_templates.py", line 110, in setup
    self._load_templates()
  File "/home/ceradon/cerabot-rewrite/cerabot/tasks/date_templates.py", line 61, in _load_templates
    self._to_date.append(template.get(1).value.lower())
AttributeError: 'DateTemplates' object has no attribute '_to_date'

I'm lost, can anybody help in figuring this out?

1
the error occurs in the constructor of the 'Bot' class so you should provide that code too.. - Ionut Hulub
Here is the code to the 'Bot' class. - ceradon
And neither class has a _to_date method, so you were expecting... what? - mVChr
self._to_date is a list object. In the first few lines of DateTemplates.__init__(). - ceradon
You're right, this is very confusing as neither start nor _load_templates is even called in the __init__ where it says the error is occurring. Very odd. You didn't happen to have renamed the start method to setup, did you? - mVChr

1 Answers

1
votes

When you call super(DateTemplates, self).__init__() this runs Bot.__init__ which calls self.setup() which runs DateTemplates.setup(), however this happens before you initialize self._to_date and so there is no list to append to yet. Move the super call in DateTemplates.__init__ to the end of the method and this should work.