def check_hostname(hostname):
"""Returns a newline separated string of reasons why the hostname is
invalid."""
# TODO: i18n
e = []
# Ahem. We can cheat here by inserting newlines where needed. Hopefully
# by the time we translate this, GTK+ will have decent layout management.
for result in validation.check_hostname(utf8(hostname)):
if result == validation.HOSTNAME_LENGTH: e.append("Must be between 1 and 63 characters long.")
elif result == validation.HOSTNAME_BADCHAR: e.append("May only contain letters, digits,\nhyphens, and dots.")
elif result == validation.HOSTNAME_BADHYPHEN: e.append("May not start or end with a hyphen.")
elif result == validation.HOSTNAME_BADDOTS: e.append('May not start or end with a dot,\n' 'or contain the sequence "..".')
return "\n".join(e)
Still says TODO:
def check_hostname( hostname) : check_hostname( utf8(hostname) ): HOSTNAME_ LENGTH:
e. append( "Must be between 1 and 63 characters long.") HOSTNAME_ BADCHAR:
e. append( "May only contain letters, digits,\nhyphens, and dots.") HOSTNAME_ BADHYPHEN:
e. append( "May not start or end with a hyphen.") HOSTNAME_ BADDOTS:
e. append( 'May not start or end with a dot,\n'
'or contain the sequence "..".')
"""Returns a newline separated string of reasons why the hostname is
invalid."""
# TODO: i18n
e = []
# Ahem. We can cheat here by inserting newlines where needed. Hopefully
# by the time we translate this, GTK+ will have decent layout management.
for result in validation.
if result == validation.
elif result == validation.
elif result == validation.
elif result == validation.
return "\n".join(e)