mpenning / ciscoconfparse

Parse, Audit, Query, Build, and Modify Arista / Cisco / Juniper / Palo Alto / F5 configurations.
http://www.pennington.net/py/ciscoconfparse/
GNU General Public License v3.0
793 stars 220 forks source link

banner motd breaks parsing #42

Closed mew1033 closed 9 years ago

mew1033 commented 9 years ago

I may be doing something wrong, but from what I can tell, the following line is breaking the parse command: banner motd

It gives this error:

Traceback (most recent call last):
  File "parse.py", line 3, in <module>
    parse = CiscoConfParse('xxx')
  File "C:\Python27\lib\site-packages\ciscoconfparse\ciscoconfparse.py", line 164, in __init__
    CiscoConfParse=self)
  File "C:\Python27\lib\site-packages\ciscoconfparse\ciscoconfparse.py", line 2116, in __init__
    self._list = self._bootstrap_obj_init(data)
  File "C:\Python27\lib\site-packages\ciscoconfparse\ciscoconfparse.py", line 2401, in _bootstrap_obj_init
    self._banner_mark_regex(BANNER_RE)
  File "C:\Python27\lib\site-packages\ciscoconfparse\ciscoconfparse.py", line 2300, in _banner_mark_regex
    if bannerdelimit in obj.text.strip():
TypeError: 'in <string>' requires string as left operand, not NoneType
mpenning commented 9 years ago

Thank you for your bug report... please add:

I tried a simple test with this (ciscoconfparse 1.2.25 on Windows Vista 64-bit), but could not reproduce the problem you have described...

c:\Python27>python
Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ciscoconfparse import CiscoConfParse
>>> CONFIG = """!
... interface FastEthernet0/0
...  ip address 1.1.1.1 255.255.255.0
... !
... banner motd ^
... Hello world
... ^
... !
... end"""
>>> parse = CiscoConfParse(CONFIG.splitlines())
>>>
mpenning commented 9 years ago

This should be fixed in 1.2.30