No description
  • Python 95.3%
  • Dockerfile 4.7%
Find a file
2025-05-10 14:41:12 +10:00
.devcontainer wip 2022-04-24 11:07:28 +10:00
.github Update unit-test.yml 2025-05-10 13:53:32 +10:00
.vscode wip 2022-04-24 11:07:28 +10:00
docs Set theme jekyll-theme-cayman 2020-08-10 23:12:49 +10:00
test-data/zonefiles fix bracket issue 2025-05-10 14:36:32 +10:00
zonefile_parser fix bracket issue 2025-05-10 14:36:32 +10:00
.gitignore unit test for lower case rclass 2022-03-02 15:28:32 +11:00
LICENSE.txt added license 2020-08-10 22:26:11 +10:00
pytest.ini begin work for #21 2022-04-19 00:00:08 +10:00
README.md Update README.md 2023-02-28 22:59:24 +11:00
requirements.txt Bump flake8 from 4.0.1 to 6.1.0 2025-05-10 04:39:51 +00:00
setup.cfg added setup.cfg 2020-08-10 22:24:56 +10:00
setup.py Update setup.py 2025-05-10 14:41:12 +10:00

zone-file-parser

unit-tests

! this package is not currently RFC compliant, but if you open up an issue on github - i'm more than likely to attempt to solve it.

install

pip install zonefile-parser

usage

import zonefile_parser

with open("zone.txt","r") as stream:
    content = stream.read()
    records = zonefile_parser.parse(content)

    for record in records:
        print(record)
{'rtype': 'SOA', 'name': 'mywebsite.com.', 'rclass': 'IN', 'rdata': {'mname': 'mywebsite.com.', 'rname': 'root.mywebsite.com.', 'serial': '2034847964', 'refresh': '7200', 'retry': '3600', 'expire': '86400', 'minimum': '3600'}, 'ttl': '3600'}
{'rtype': 'A', 'name': 'mywebsite.com.', 'rclass': 'IN', 'rdata': {'value': '105.33.55.52'}, 'ttl': '7200'}
{'rtype': 'MX', 'name': 'mywebsite.com.', 'rclass': 'IN', 'rdata': {'priority': '10', 'host': 'alt3.aspmx.l.google.com.'}, 'ttl': '1'}
{'rtype': 'MX', 'name': 'mywebsite.com.', 'rclass': 'IN', 'rdata': {'priority': '5', 'host': 'alt2.aspmx.l.google.com.'}, 'ttl': '1'}
{'rtype': 'TXT', 'name': 'mywebsite.com.', 'rclass': 'IN', 'rdata': {'value': 'v=spf1 include:_spf.google.com ~all'}, 'ttl': '1'}

Detailed Documentation -> https://aredwood.github.io/zonefile-parser/