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

[Bug]: save_as not working #9

Closed
1 task done
rst7123 opened this issue Apr 16, 2024 · 1 comment
Closed
1 task done

[Bug]: save_as not working #9

rst7123 opened this issue Apr 16, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@rst7123
Copy link

rst7123 commented Apr 16, 2024

Contact Details

No response

What happened?

When executing save_as i ran into an error instead of writing the config into the new file.

I was also able to fix this manually by changing ciscoconfparse2/ciscoconfparse2.py line 3548 to for line in self.objs.as_text though i am not sure that this is the intended way.

btw. this tool saved me a ton of python-programming and therefore time while rearranging configuration-files. Thanks a lot!

CiscoConfParse Version

0.7.43

What Operating System are you using?

MacOS

What Python version(s) have this problem?

Python 3.9

Show us how to reproduce the problem. Please tell us if the problem is specific to certain inputs or situations.

from ciscoconfparse2 import CiscoConfParse

parse = CiscoConfParse('example.conf', syntax='ios')
parse.save_as("example_parsed.conf")

Python tracebacks

Traceback (most recent call last):

> File "/Users/tabea.rieth/work/python_ztp/parser.py", line 51, in <module>
    origConfig.save_as("example_parsed.conf")
    │          └ <function CiscoConfParse.save_as at 0x1041325e0><CiscoConfParse: 484 lines / syntax: ios / comment delimiters: ['!'] / auto_indent_width: 1 / factory: False / ignore_blank_l...

  File "/Users/tabea.rieth/Library/Python/3.9/lib/python/site-packages/ciscoconfparse2/ciscoconfparse2.py", line 3553, in save_as
    raise ee
  File "/Users/tabea.rieth/Library/Python/3.9/lib/python/site-packages/ciscoconfparse2/ciscoconfparse2.py", line 3548, in save_as
    for line in self.as_text:
                └ <CiscoConfParse: 484 lines / syntax: ios / comment delimiters: ['!'] / auto_indent_width: 1 / factory: False / ignore_blank_l...

AttributeError: 'CiscoConfParse' object has no attribute 'as_text'
  File "/Users/tabea.rieth/work/python_ztp/parser.py", line 51, in <module>
    origConfig.save_as("example_parsed.conf")
  File "/Users/tabea.rieth/Library/Python/3.9/lib/python/site-packages/loguru/_logger.py", line 1277, in catch_wrapper
    return function(*args, **kwargs)
  File "/Users/tabea.rieth/Library/Python/3.9/lib/python/site-packages/ciscoconfparse2/ciscoconfparse2.py", line 3553, in save_as
    raise ee
  File "/Users/tabea.rieth/Library/Python/3.9/lib/python/site-packages/ciscoconfparse2/ciscoconfparse2.py", line 3548, in save_as
    for line in self.as_text:
AttributeError: 'CiscoConfParse' object has no attribute 'as_text'

Relevant log output

No response

Code of Conduct

@rst7123 rst7123 added the bug Something isn't working label Apr 16, 2024
@mpenning
Copy link
Owner

mpenning commented Apr 16, 2024

Wow, that was a big test escape. Thank you for finding it. It's fixed (and tested) in 0.7.45.

@mpenning mpenning self-assigned this Apr 16, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants