Update dnspython-2.2.0

This commit is contained in:
JonnyWong16 2021-10-14 21:36:41 -07:00
parent 4b28040d59
commit 4d62245cf5
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
111 changed files with 9077 additions and 5877 deletions

View file

@ -1,4 +1,6 @@
# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
# Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license
# Copyright (C) 2003-2017 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@ -16,11 +18,9 @@
"""DNS TTL conversion."""
import dns.exception
from ._compat import long
class BadTTL(dns.exception.SyntaxError):
"""DNS TTL value is not well-formed."""
@ -29,33 +29,34 @@ def from_text(text):
The BIND 8 units syntax for TTLs (e.g. '1w6d4h3m10s') is supported.
@param text: the textual TTL
@type text: string
@raises dns.ttl.BadTTL: the TTL is not well-formed
@rtype: int
*text*, a ``str``, the textual TTL.
Raises ``dns.ttl.BadTTL`` if the TTL is not well-formed.
Returns an ``int``.
"""
if text.isdigit():
total = long(text)
total = int(text)
else:
if not text[0].isdigit():
raise BadTTL
total = long(0)
current = long(0)
total = 0
current = 0
for c in text:
if c.isdigit():
current *= 10
current += long(c)
current += int(c)
else:
c = c.lower()
if c == 'w':
total += current * long(604800)
total += current * 604800
elif c == 'd':
total += current * long(86400)
total += current * 86400
elif c == 'h':
total += current * long(3600)
total += current * 3600
elif c == 'm':
total += current * long(60)
total += current * 60
elif c == 's':
total += current
else:
@ -63,6 +64,6 @@ def from_text(text):
current = 0
if not current == 0:
raise BadTTL("trailing integer")
if total < long(0) or total > long(2147483647):
if total < 0 or total > 2147483647:
raise BadTTL("TTL should be between 0 and 2^31 - 1 (inclusive)")
return total