(
text: Any,
origin: dns.name.Name | str | None = None,
rdclass: dns.rdataclass.RdataClass = dns.rdataclass.IN,
relativize: bool = True,
zone_factory: Any = Zone,
filename: str | None = None,
allow_include: bool = False,
check_origin: bool = True,
idna_codec: dns.name.IDNACodec | None = None,
allow_directives: bool | Iterable[str] = True,
)
| 1208 | |
| 1209 | |
| 1210 | def _from_text( |
| 1211 | text: Any, |
| 1212 | origin: dns.name.Name | str | None = None, |
| 1213 | rdclass: dns.rdataclass.RdataClass = dns.rdataclass.IN, |
| 1214 | relativize: bool = True, |
| 1215 | zone_factory: Any = Zone, |
| 1216 | filename: str | None = None, |
| 1217 | allow_include: bool = False, |
| 1218 | check_origin: bool = True, |
| 1219 | idna_codec: dns.name.IDNACodec | None = None, |
| 1220 | allow_directives: bool | Iterable[str] = True, |
| 1221 | ) -> Zone: |
| 1222 | # See the comments for the public APIs from_text() and from_file() for |
| 1223 | # details. |
| 1224 | |
| 1225 | # 'text' can also be a file, but we don't publish that fact |
| 1226 | # since it's an implementation detail. The official file |
| 1227 | # interface is from_file(). |
| 1228 | |
| 1229 | if filename is None: |
| 1230 | filename = "<string>" |
| 1231 | zone = zone_factory(origin, rdclass, relativize=relativize) |
| 1232 | with zone.writer(True) as txn: |
| 1233 | tok = dns.tokenizer.Tokenizer(text, filename, idna_codec=idna_codec) |
| 1234 | reader = dns.zonefile.Reader( |
| 1235 | tok, |
| 1236 | rdclass, |
| 1237 | txn, |
| 1238 | allow_include=allow_include, |
| 1239 | allow_directives=allow_directives, |
| 1240 | ) |
| 1241 | try: |
| 1242 | reader.read() |
| 1243 | except dns.zonefile.UnknownOrigin: |
| 1244 | # for backwards compatibility |
| 1245 | raise UnknownOrigin |
| 1246 | # Now that we're done reading, do some basic checking of the zone. |
| 1247 | if check_origin: |
| 1248 | zone.check_origin() |
| 1249 | return zone |
| 1250 | |
| 1251 | |
| 1252 | def from_text( |
no test coverage detected
searching dependent graphs…