Exemplo n.º 1
0
        def urlhandler(default, toconf):
            answer = ask('Site URL', 'https://example.com/')
            try:
                answer = answer.decode('utf-8')
            except (AttributeError, UnicodeDecodeError):
                pass
            if not answer.startswith(u'http'):
                print(
                    "    ERROR: You must specify a protocol (http or https).")
                urlhandler(default, toconf)
                return
            if not answer.endswith('/'):
                print("    The URL does not end in '/' -- adding it.")
                answer += '/'

            dst_url = urlsplit(answer)
            try:
                dst_url.netloc.encode('ascii')
            except (UnicodeEncodeError, UnicodeDecodeError):
                # The IDN contains characters beyond ASCII.  We must convert it
                # to Punycode. (Issue #1644)
                nl = dst_url.netloc.encode('idna')
                answer = urlunsplit((dst_url.scheme, nl, dst_url.path,
                                     dst_url.query, dst_url.fragment))
                print("    Converting to Punycode:", answer)

            SAMPLE_CONF['SITE_URL'] = answer
Exemplo n.º 2
0
        def urlhandler(default, toconf):
            answer = ask("Site URL", "https://example.com/")
            try:
                answer = answer.decode("utf-8")
            except (AttributeError, UnicodeDecodeError):
                pass
            if not answer.startswith("http"):
                print("    ERROR: You must specify a protocol (http or https).")
                urlhandler(default, toconf)
                return
            if not answer.endswith("/"):
                print("    The URL does not end in '/' -- adding it.")
                answer += "/"

            dst_url = urlsplit(answer)
            try:
                dst_url.netloc.encode("ascii")
            except (UnicodeEncodeError, UnicodeDecodeError):
                # The IDN contains characters beyond ASCII.  We must convert it
                # to Punycode. (Issue #1644)
                nl = dst_url.netloc.encode("idna")
                answer = urlunsplit((dst_url.scheme, nl, dst_url.path, dst_url.query, dst_url.fragment))
                print("    Converting to Punycode:", answer)

            SAMPLE_CONF["SITE_URL"] = answer