Did I find the right examples for you? yes no

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)
Returns True if the given *hostname* is valid according to RFC rules.  Works
with Internationalized Domain Names (IDN) and optionally, hostnames with an
underscore (if *allow_underscore* is True).

The rules for hostnames:

    * Must be less than 255 characters.
    * Individual labels (separated by dots) must be <= 63 characters.
    * Only the ASCII alphabet (A-Z) is allowed along with dashes (-) and dots (.).
    * May not start with a dash or a dot.(more...)

        def valid_hostname(hostname, allow_underscore=False):
    """
    Returns True if the given *hostname* is valid according to RFC rules.  Works
    with Internationalized Domain Names (IDN) and optionally, hostnames with an
    underscore (if *allow_underscore* is True).

    The rules for hostnames:

        * Must be less than 255 characters.
        * Individual labels (separated by dots) must be <= 63 characters.
        * Only the ASCII alphabet (A-Z) is allowed along with dashes (-) and dots (.).
        * May not start with a dash or a dot.
        * May not end with a dash.
        * If an IDN, when converted to Punycode it must comply with the above.

    IP addresses will be validated according to their well-known specifications.

    Examples::

        >>> valid_hostname('foo.bar.com.') # Standard FQDN
        True
        >>> valid_hostname('2foo') # Short hostname
        True
        >>> valid_hostname('-2foo') # No good:  Starts with a dash
        False
        >>> valid_hostname('host_a') # No good: Can't have underscore
        False
        >>> valid_hostname('host_a', allow_underscore=True) # Now it'll validate
        True
        >>> valid_hostname(u'????????.jp') # Example valid IDN
        True
    """
    # Convert to Punycode if an IDN
    if isinstance(hostname, str):
        try:
            hostname = hostname.encode('idna')
        except UnicodeError: # Can't convert to Punycode: Bad hostname
            return False
    if len(hostname) > 255:
        return False
    if hostname[-1:] == b".": # Strip the tailing dot if present
        hostname = hostname[:-1]
    allowed = re.compile(b"(?!-)[A-Z\d-]{1,63}(?
    


src/g/a/GateOne-HEAD/gateone/core/server.py   GateOne(Download)
from .utils import json_encode, recursive_chown, ChownError, get_or_cache
from .utils import write_pid, read_pid, remove_pid, drop_privileges
from .utils import check_write_permissions, get_applications, valid_hostname
from .utils import total_seconds, MEMO
from .configuration import apply_cli_overrides, define_options, SettingsError
            # Treat the list of valid origins as regular expressions
            for check_origin in valid_origins:
                if valid_hostname(check_origin):
                    continue # Valid hostnames aren't regular expressions
                match = re.match(check_origin, origin)