def parse_option(self, option, block_name, *values):
        """ Parse domain values for option.
            """
        _extra_subs = ('www', 'm', 'mobile')

        if len(values) == 0:  # expect some values here..
            raise ValueError

        for value in values:
            value = value.lower()

            # if it doesn't look like a protocol, assume http
            # (e.g. only domain supplied)
            if not _RE_PROTOCOL.match(value):
                value = 'http://' + value

            # did it parse? pull hostname/domain
            parsed = urlparse.urlparse(value)
            if parsed:
                domain = parsed.hostname

                if domain and _RE_TLD.search(domain):  # must have a TLD
                    # doesn't have subdomain, tack on www, m, and mobile
                    # for good measure. note, this check fails for
                    # multi-part TLDs, e.g. .co.uk
                    domain = _RE_WWW_SUB.sub('', domain)  # strip "www."

                    if len(domain.split('.')) == 2:
                        for sub in _extra_subs:
                            self.domains.add('{0}.{1}'.format(sub, domain))

                    self.domains.add(domain)

        # no domains.. must have failed
        if not self.domains:
            raise ValueError
def parse_option ( self , option , block_name , * values ) : _extra_subs = ( 'www' , 'm' , 'mobile' ) if len ( values ) == 0 : raise ValueError for value in values : value = value . lower ( ) if not _RE_PROTOCOL . match ( value ) : value = 'http://' + value parsed = urlparse . urlparse ( value ) if parsed : domain = parsed . hostname if domain and _RE_TLD . search ( domain ) : domain = _RE_WWW_SUB . sub ( '' , domain ) if len ( domain . split ( '.' ) ) == 2 : for sub in _extra_subs : self . domains . add ( '{0}.{1}' . format ( sub , domain ) ) self . domains . add ( domain ) if not self . domains : raise ValueError
Parse domain values for option.