Merge "Remove invalid use of jsonschema.compat"
This commit is contained in:
commit
764185db7e
@ -16,7 +16,6 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
import jsonschema
|
import jsonschema
|
||||||
from jsonschema import compat
|
|
||||||
import netaddr
|
import netaddr
|
||||||
|
|
||||||
|
|
||||||
@ -56,7 +55,7 @@ draft4_format_checker = jsonschema.draft4_format_checker
|
|||||||
@draft3_format_checker.checks("ip-address")
|
@draft3_format_checker.checks("ip-address")
|
||||||
@draft4_format_checker.checks("ipv4")
|
@draft4_format_checker.checks("ipv4")
|
||||||
def is_ipv4(instance):
|
def is_ipv4(instance):
|
||||||
if not isinstance(instance, compat.str_types):
|
if not isinstance(instance, str):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -76,7 +75,7 @@ def is_ipv4(instance):
|
|||||||
@draft3_format_checker.checks("ipv6")
|
@draft3_format_checker.checks("ipv6")
|
||||||
@draft4_format_checker.checks("ipv6")
|
@draft4_format_checker.checks("ipv6")
|
||||||
def is_ipv6(instance):
|
def is_ipv6(instance):
|
||||||
if not isinstance(instance, compat.str_types):
|
if not isinstance(instance, str):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -90,7 +89,7 @@ def is_ipv6(instance):
|
|||||||
@draft3_format_checker.checks("host-name")
|
@draft3_format_checker.checks("host-name")
|
||||||
@draft4_format_checker.checks("hostname")
|
@draft4_format_checker.checks("hostname")
|
||||||
def is_hostname(instance):
|
def is_hostname(instance):
|
||||||
if not isinstance(instance, compat.str_types):
|
if not isinstance(instance, str):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if not re.match(RE_HOSTNAME, instance):
|
if not re.match(RE_HOSTNAME, instance):
|
||||||
@ -101,7 +100,7 @@ def is_hostname(instance):
|
|||||||
|
|
||||||
@draft4_format_checker.checks("ns-hostname")
|
@draft4_format_checker.checks("ns-hostname")
|
||||||
def is_ns_hostname(instance):
|
def is_ns_hostname(instance):
|
||||||
if not isinstance(instance, compat.str_types):
|
if not isinstance(instance, str):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# BIND doesn't like *.host.com. see bug #1533299
|
# BIND doesn't like *.host.com. see bug #1533299
|
||||||
@ -114,7 +113,7 @@ def is_ns_hostname(instance):
|
|||||||
@draft3_format_checker.checks("ip-or-host")
|
@draft3_format_checker.checks("ip-or-host")
|
||||||
@draft4_format_checker.checks("ip-or-host")
|
@draft4_format_checker.checks("ip-or-host")
|
||||||
def is_ip_or_host(instance):
|
def is_ip_or_host(instance):
|
||||||
if not isinstance(instance, compat.str_types):
|
if not isinstance(instance, str):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if not re.match(RE_ZONENAME, instance)\
|
if not re.match(RE_ZONENAME, instance)\
|
||||||
@ -130,7 +129,7 @@ def is_ip_or_host(instance):
|
|||||||
@draft3_format_checker.checks("zone-name")
|
@draft3_format_checker.checks("zone-name")
|
||||||
@draft4_format_checker.checks("zonename")
|
@draft4_format_checker.checks("zonename")
|
||||||
def is_zonename(instance):
|
def is_zonename(instance):
|
||||||
if not isinstance(instance, compat.str_types):
|
if not isinstance(instance, str):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if not re.match(RE_ZONENAME, instance):
|
if not re.match(RE_ZONENAME, instance):
|
||||||
@ -141,7 +140,7 @@ def is_zonename(instance):
|
|||||||
|
|
||||||
@draft4_format_checker.checks("srv-hostname")
|
@draft4_format_checker.checks("srv-hostname")
|
||||||
def is_srv_hostname(instance):
|
def is_srv_hostname(instance):
|
||||||
if not isinstance(instance, compat.str_types):
|
if not isinstance(instance, str):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if not re.match(RE_SRV_HOST_NAME, instance):
|
if not re.match(RE_SRV_HOST_NAME, instance):
|
||||||
@ -152,7 +151,7 @@ def is_srv_hostname(instance):
|
|||||||
|
|
||||||
@draft4_format_checker.checks("txt-data")
|
@draft4_format_checker.checks("txt-data")
|
||||||
def is_txt_data(instance):
|
def is_txt_data(instance):
|
||||||
if not isinstance(instance, compat.str_types):
|
if not isinstance(instance, str):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if instance.endswith('\\'):
|
if instance.endswith('\\'):
|
||||||
@ -164,7 +163,7 @@ def is_txt_data(instance):
|
|||||||
@draft3_format_checker.checks("tld-name")
|
@draft3_format_checker.checks("tld-name")
|
||||||
@draft4_format_checker.checks("tldname")
|
@draft4_format_checker.checks("tldname")
|
||||||
def is_tldname(instance):
|
def is_tldname(instance):
|
||||||
if not isinstance(instance, compat.str_types):
|
if not isinstance(instance, str):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if not re.match(RE_TLDNAME, instance):
|
if not re.match(RE_TLDNAME, instance):
|
||||||
@ -176,7 +175,7 @@ def is_tldname(instance):
|
|||||||
@draft3_format_checker.checks("email")
|
@draft3_format_checker.checks("email")
|
||||||
@draft4_format_checker.checks("email")
|
@draft4_format_checker.checks("email")
|
||||||
def is_email(instance):
|
def is_email(instance):
|
||||||
if not isinstance(instance, compat.str_types):
|
if not isinstance(instance, str):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# A valid email address. We use the RFC1035 version of "valid".
|
# A valid email address. We use the RFC1035 version of "valid".
|
||||||
@ -193,7 +192,7 @@ def is_email(instance):
|
|||||||
|
|
||||||
@draft4_format_checker.checks("sshfp")
|
@draft4_format_checker.checks("sshfp")
|
||||||
def is_sshfp_fingerprint(instance):
|
def is_sshfp_fingerprint(instance):
|
||||||
if not isinstance(instance, compat.str_types):
|
if not isinstance(instance, str):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if not re.match(RE_SSHFP_FINGERPRINT, instance):
|
if not re.match(RE_SSHFP_FINGERPRINT, instance):
|
||||||
@ -205,7 +204,7 @@ def is_sshfp_fingerprint(instance):
|
|||||||
@draft3_format_checker.checks("uuid")
|
@draft3_format_checker.checks("uuid")
|
||||||
@draft4_format_checker.checks("uuid")
|
@draft4_format_checker.checks("uuid")
|
||||||
def is_uuid(instance):
|
def is_uuid(instance):
|
||||||
if not isinstance(instance, compat.str_types):
|
if not isinstance(instance, str):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if not re.match(RE_UUID, instance):
|
if not re.match(RE_UUID, instance):
|
||||||
@ -219,7 +218,7 @@ def is_uuid(instance):
|
|||||||
def is_floating_ip_id(instance):
|
def is_floating_ip_id(instance):
|
||||||
# TODO(kiall): Apparently, this is used in exactly zero places outside the
|
# TODO(kiall): Apparently, this is used in exactly zero places outside the
|
||||||
# tests. Determine if we should remove this code...
|
# tests. Determine if we should remove this code...
|
||||||
if not isinstance(instance, compat.str_types):
|
if not isinstance(instance, str):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if not re.match(RE_FIP_ID, instance):
|
if not re.match(RE_FIP_ID, instance):
|
||||||
@ -231,7 +230,7 @@ def is_floating_ip_id(instance):
|
|||||||
@draft3_format_checker.checks("ip-and-port")
|
@draft3_format_checker.checks("ip-and-port")
|
||||||
@draft4_format_checker.checks("ipandport")
|
@draft4_format_checker.checks("ipandport")
|
||||||
def is_ip_and_port(instance):
|
def is_ip_and_port(instance):
|
||||||
if not isinstance(instance, compat.str_types):
|
if not isinstance(instance, str):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if not re.match(RE_IP_AND_PORT, instance):
|
if not re.match(RE_IP_AND_PORT, instance):
|
||||||
|
Loading…
Reference in New Issue
Block a user