MCPcopy Create free account
hub / github.com/rthalley/dnspython / get_string

Method get_string

dns/tokenizer.py:569–584  ·  view source on GitHub ↗

Read the next token and interpret it as a string. Raises dns.exception.SyntaxError if not a string. Raises dns.exception.SyntaxError if token value length exceeds max_length (if specified). Returns a string.

(self, max_length: int | None = None)

Source from the content-addressed store, hash-verified

567 return value
568
569 def get_string(self, max_length: int | None = None) -> str:
570 """Read the next token and interpret it as a string.
571
572 Raises dns.exception.SyntaxError if not a string.
573 Raises dns.exception.SyntaxError if token value length
574 exceeds max_length (if specified).
575
576 Returns a string.
577 """
578
579 token = self.get().unescape()
580 if not (token.is_identifier() or token.is_quoted_string()):
581 raise dns.exception.SyntaxError("expecting a string")
582 if max_length and len(token.value) > max_length:
583 raise dns.exception.SyntaxError("string too long")
584 return token.value
585
586 def get_identifier(self) -> str:
587 """Read the next token, which should be an identifier.

Callers 15

testGetStringMethod · 0.95
_header_lineMethod · 0.80
from_textMethod · 0.80
from_textMethod · 0.80
from_textMethod · 0.80
from_textMethod · 0.80
from_textMethod · 0.80
from_textMethod · 0.80
from_textMethod · 0.80
from_textMethod · 0.80
from_textMethod · 0.80
from_textMethod · 0.80

Calls 4

getMethod · 0.95
unescapeMethod · 0.80
is_identifierMethod · 0.80
is_quoted_stringMethod · 0.80

Tested by 1

testGetStringMethod · 0.76