# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-"""Tokenize DNS master file format"""
+"""Tokenize DNS zone file format"""
import io
import sys
class Token:
- """A DNS master file format token.
+ """A DNS zone file format token.
ttype: The token type
value: The token value
class Tokenizer:
- """A DNS master file format tokenizer.
+ """A DNS zone file format tokenizer.
A token object is basically a (type, value) tuple. The valid
types are EOF, EOL, WHITESPACE, IDENTIFIER, QUOTED_STRING,
import os
import dns.exception
-import dns.masterfile
import dns.name
import dns.node
import dns.rdataclass
import dns.transaction
import dns.ttl
import dns.grange
+import dns.zonefile
class BadZone(dns.exception.DNSException):
*origin* is the origin of the zone. It may be a ``dns.name.Name``,
a ``str``, or ``None``. If ``None``, then the zone's origin will
- be set by the first ``$ORIGIN`` line in a masterfile.
+ be set by the first ``$ORIGIN`` line in a zone file.
*rdclass*, an ``int``, the zone's rdata class; the default is class IN.
def from_text(text, origin=None, rdclass=dns.rdataclass.IN,
relativize=True, zone_factory=Zone, filename=None,
allow_include=False, check_origin=True, idna_codec=None):
- """Build a zone object from a master file format string.
+ """Build a zone object from a zone file format string.
- *text*, a ``str``, the master file format input.
+ *text*, a ``str``, the zone file format input.
*origin*, a ``dns.name.Name``, a ``str``, or ``None``. The origin
of the zone; if not specified, the first ``$ORIGIN`` statement in the
- masterfile will determine the origin of the zone.
+ zone file will determine the origin of the zone.
*rdclass*, an ``int``, the zone's rdata class; the default is class IN.
zone = zone_factory(origin, rdclass, relativize=relativize)
with zone.writer(True) as txn:
tok = dns.tokenizer.Tokenizer(text, filename, idna_codec=idna_codec)
- reader = dns.masterfile.Reader(tok, rdclass, txn,
- allow_include=allow_include)
+ reader = dns.zonefile.Reader(tok, rdclass, txn,
+ allow_include=allow_include)
try:
reader.read()
- except dns.masterfile.UnknownOrigin:
+ except dns.zonefile.UnknownOrigin:
# for backwards compatibility
raise dns.zone.UnknownOrigin
# Now that we're done reading, do some basic checking of the zone.
def from_file(f, origin=None, rdclass=dns.rdataclass.IN,
relativize=True, zone_factory=Zone, filename=None,
allow_include=True, check_origin=True):
- """Read a master file and build a zone object.
+ """Read a zone file and build a zone object.
*f*, a file or ``str``. If *f* is a string, it is treated
as the name of a file to open.
*origin*, a ``dns.name.Name``, a ``str``, or ``None``. The origin
of the zone; if not specified, the first ``$ORIGIN`` statement in the
- masterfile will determine the origin of the zone.
+ zone file will determine the origin of the zone.
*rdclass*, an ``int``, the zone's rdata class; the default is class IN.
class Reader:
- """Read a DNS master file into a transaction."""
+ """Read a DNS zone file into a transaction."""
def __init__(self, tok, rdclass, txn, allow_include=False):
self.tok = tok
break
def _rr_line(self):
- """Process one line from a DNS master file."""
+ """Process one line from a DNS zone file."""
# Name
if self.current_origin is None:
raise UnknownOrigin
def _generate_line(self):
# range lhs [ttl] [class] type rhs [ comment ]
"""Process one line containing the GENERATE statement from a DNS
- master file."""
+ zone file."""
if self.current_origin is None:
raise UnknownOrigin
self.txn.add(name, ttl, rd)
def read(self):
- """Read a DNS master file and build a zone object.
+ """Read a DNS zone file and build a zone object.
@raises dns.zone.NoSOA: No SOA RR was found at the zone origin
@raises dns.zone.NoNS: No NS RRset was found at the zone origin
self._generate_line()
else:
raise dns.exception.SyntaxError(
- "Unknown master file directive '" + c + "'")
+ "Unknown zone file directive '" + c + "'")
continue
self.tok.unget(token)
self._rr_line()