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

Parser returns last 2 entries #4

Open
doman18 opened this issue Jan 13, 2022 · 1 comment
Open

Parser returns last 2 entries #4

doman18 opened this issue Jan 13, 2022 · 1 comment

Comments

@doman18
Copy link

doman18 commented Jan 13, 2022

I have dhcp_static.conf which has 118 IP assigments and i want to parse with python. This file will be included in dhcpd.conf file.

dhcp_static.conf

host host_0 {
  hardware ethernet 18:DB:F2:5E:00:00;
  fixed-address 10.12.24.81;
}
host host_1 {
  hardware ethernet D4:AE:52:BD:00:00;
  fixed-address 10.12.42.1;
}

... (many more) ...

host host_118 {
  hardware ethernet DC:A6:32:B7:00:00;
  fixed-address 10.12.67.22;
}

assigments.py (my script)

import os, types, iscpy

NAMED_FILE = 'dhcp_static.conf'

named_file = open(NAMED_FILE).read()
# print("named_file:",named_file)

isc_arr = iscpy.ParseISCString(named_file)
print(isc_arr)

Result:

$ python assigments.py 
[{'host host_117': {'hardware': 'ethernet 18:DB:F2:5E:00:00', 'fixed-address': '10.12.24.81'}}, {'host host_118': {'hardware': 'ethernet DC:A6:32:B7:00:00', 'fixed-address': '10.12.67.22'}}]

If i uncomment printing named_file then i see whole file. So it means that the problem lies in parser.

Additional info:

$ python --version
Python 3.8.10
$ pip freeze
certifi==2021.10.8
charset-normalizer==2.0.10
idna==3.3
iscpy==1.8
openssh-wrapper==0.4
proxmoxer==1.2.0
requests==2.27.1
urllib3==1.26.8
@egberts
Copy link
Owner

egberts commented Jan 13, 2022

@utamid maintains the original.

I forked this git clone from his repository.

It has been awhile since I've visited this repo (in fact, I am thinking about deleting my copy of this repository).

Perhaps you can repost the issue over at the https://github.com/utamid/iscpy_modified.

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