Deduce the root domain name - usually a 'naked' domain.
    
    This only needs to be done prior to the first deployment
492592
def _root_domain():
    

    if not hasattr(env,'root_domain'):
        cwd = os.getcwd().split(os.sep)
        domain = ''
        #if the first env.host has a domain name then we'll use that
        #since there are no top level domains that have numbers in them we can test env.host

        username, host, port = normalize(env.hosts[0])
        if host[-1] in string.ascii_letters:
            domain_parts = env.host.split('.')
            length = len(domain_parts)
            if length==2:
                #assumes .com .net etc so we want the full hostname for the domain
                domain = host
            elif length==3 and len(domain_parts[-1])==2:
                #assume country tld so we want the full hostname for domain
                domain = host
            elif length >=3:
                #assume the first part is the hostname of the machine
                domain = '.'.join(domain[1:])
        #we'll just pick the first directory in the path which has a period.
        else:
            for d in cwd:
                if '.' in d: 
                    domain = d
        if not domain and env.INTERACTIVE:
            domain = prompt('Enter the root domain for this project ',default='example.com')
        else:
            domain = 'example.com'
        env.root_domain = domain
    return env.root_domain
504132
def netloc_no_www(url):
    
    ext = tldextract.extract(url)
    if ext.subdomain and ext.subdomain != 'www':
        return '%s.%s.%s' % (ext.subdomain, ext.domain, ext.tld) 
    else:
        return '%s.%s' % (ext.domain, ext.tld)
591941
def security(self, domain):
        '''
        '''
        uri = self._uris["security"].format(domain)
        return self.get_parse(uri)
21012
def domain_parse(url):
    
    url = url.lower()
    if not url.startswith('http://') and not url.startswith('https://'):
        url = '{schema}{host}'.format(schema='http://', host=url)
    url = urlparse(url)
    if not url.hostname:
        raise ValueError('Invalid domain provided')

    # Strip www prefix any additional URL data
    url = urlparse('{scheme}://{host}'.format(scheme=url.scheme, host=url.hostname.lstrip('www.')))
    return url
938398
def lookup_domain(domain, nameservers=[], rtype="A",
                  exclude_nameservers=[], timeout=2):
    """"""
    dns_exp = DNSQuery(domains=[domain], nameservers=nameservers, rtype=rtype,
                       exclude_nameservers=exclude_nameservers, timeout=timeout)
    return dns_exp.lookup_domain(domain)
619921
def extract_domain(var_name, output):
    

    var = getenv(var_name)

    if var:
        p = urlparse(var)
        output.append(p.hostname)
948266
def get_effective_domain_id(request):
    
    default_domain = get_default_domain(request)
    domain_id = default_domain.get('id')
    domain_name = default_domain.get('name')
    return None if domain_name == DEFAULT_DOMAIN else domain_id
851171
@Deprecated
  public static boolean verifyHostName(String hostname, String pattern) {
    String canonicalHostname;
    if (hostname.startsWith("[") && hostname.endsWith("]")) {
      // IPv6 address like [2001:db8:0:1:1:1:1:1]
      canonicalHostname = hostname.substring(1, hostname.length() - 1);
    } else {
      // This converts unicode domain name to ASCII
      try {
        canonicalHostname = IDN.toASCII(hostname);
      } catch (IllegalArgumentException e) {
        // e.g. hostname is invalid
        return false;
      }
    }
    return PGjdbcHostnameVerifier.INSTANCE.verifyHostName(canonicalHostname, pattern);
  }
252259
private static SiteDomainInfo getDomainInfo(Collection<String> uris) {

        Set<String> rootDomains = Sets.newHashSet();
        Set<String> domains = Sets.newHashSet();
        boolean invalidPort = false;

        for (String uriStr : uris) {

            try {
                URI uri = new URI(uriStr);
                int port = uri.getPort();
                if (!((port == 80) || (port == 443) || (port == -1))) {
                    invalidPort = true;
                }
                String rootDomain = getDomainRoot(uri);
                if (rootDomain == null) {
                    LOG.warn("Host is not under public suffix, skipping it: " + uri);
                    continue;
                }
                domains.add(uri.getHost());
                rootDomains.add(rootDomain);
            } catch (URISyntaxException e) {
                LOG.warn("getDomainInfo: invalid URI " + uriStr, e);
                continue;
            }
        }
        String rootDomain = (rootDomains.size() == 1 ? rootDomains.iterator().next() : null);
        return new SiteDomainInfo(domains, rootDomain, invalidPort);
    }
666280
def extract_domain(host):
    
    host = re.sub('https?://', '', host)
    host = re.match('([^/]+)', host).groups()[0]
    domain = '.'.join(host.split('.')[-2:])
    if domain in _domains:
        domain = '.'.join(host.split('.')[-3:])
    return domain
800000
def domain(self):
        
        remove_pac = self.cleanup.replace(
            "https://", "").replace("http://", "").replace("www.", "")
        try:
            return remove_pac.split('/')[0]
        except:
            return None
797983
private void init(){

		// First try identifying a prefix
		String[] prefix = name.split(":", 2);
		mySource = null;
		if(prefix.length > 1) {
			// Match Source prefixes
			String suffix = prefix[1];
			try {
				mySource = Source.valueOf(prefix[0].toUpperCase());
			} catch( IllegalArgumentException e ) {
				// unrecognized prefix; fall back on guessing
				mySource = null;
			}
			if(mySource != null) {
				switch( mySource) {
				case SCOP:
					if( ! initFromScop(suffix) )
						throw new IllegalArgumentException("Malformed SCOP domain name:"+suffix);
					return;
				case PDP:
					if( ! initFromPDP(name) )
						throw new IllegalArgumentException("Malformed PDP domain name:"+suffix);
					return;
				case CATH:
					if( ! initFromCATH(suffix) )
						throw new IllegalArgumentException("Malformed CATH domain name:"+suffix);
					return;
				case BIO:
					if( ! initFromBIO(name) )
						throw new IllegalArgumentException("Malformed BIO name:"+suffix);
					return;
				case ECOD:
					if( ! initFromECOD(suffix) )
						throw new IllegalArgumentException("Malformed ECOD domain name:"+suffix);
					return;
				case PDB:
					if( ! initFromPDB(suffix) )
						throw new IllegalArgumentException("Malformed PDB specification:"+suffix);
					return;
				case FILE:
					// Treat file:/ prefixes as URLs
					if( ! suffix.startsWith("/")) {
						// Otherwise, treat as file
						initFromFile();
						return;
					}
					// fall through to URL case
				case URL:
					if( ! initFromURL(name))
						throw new IllegalArgumentException("Malformed URL specification:"+suffix);
					return;
				default:
					throw new IllegalStateException("Unimplemented Source "+mySource);
				}
			}
		}

		// No known prefix, so revert to guessing

		// First guess regex-based identifiers
		// SCOP domain
		if( initFromScop(name) )
			return;
		// CATH
		if( initFromCATH(name) )
			return;
		// ECOD
		if( initFromECOD(name) )
			return;
		// Never guess BIO or PDP

		// URL
		if( initFromURL(name) )
			return;

		// Guess FILE based on file existence
		File file = new File(FileDownloadUtils.expandUserHome(name));
		if( file.canRead() && !file.isDirectory() ) {
			// an attempt to mitigate issue #398. It doesn't fix it but it catches the most common case of passing a pdb id and finding a file in working dir matching it
			if (name.matches("\\d\\w\\w\\w")) {
				// the plain pdb id case, this is unlikely to be what the user wants: let's let it through but warn about it
				logger.warn("Provided 4-letter structure name '{}' matches "
						+ "file name in directory {}. Will read structure "
						+ "data from file {} and not consider the name as a "
						+ "structure identifier. If this is not what you "
						+ "want, use 'FILE:{}'",
						name, file.getAbsoluteFile().getParent(),
						file.getAbsolutePath(), name);
			} else {
				logger.info("Provided structure name '{}' matches "
						+ "file name in directory {}. Will read structure "
						+ "data from file {}.",
						name, file.getAbsoluteFile().getParent(),
						file.getAbsolutePath());
			}

			initFromFile();
			return;
		}

		// Default to PDB
		initFromPDB( name );
	}
594013
def domain_name=(domain_name)
      if domain_name.nil?
        fail ArgumentError, "domain_name cannot be nil"
      end

      if domain_name.to_s.length > 255
        fail ArgumentError, "invalid value for 'domain_name', the character length must be smaller than or equal to 255."
      end

      if domain_name.to_s.length < 1
        fail ArgumentError, "invalid value for 'domain_name', the character length must be great than or equal to 1."
      end

      @domain_name = domain_name
    end
187051
def is_in_current_deployment(server, extra_prefix=""):
    
    return re.match(r"^%s" % '-'.join([DEFAULT_PREFIX, extra_prefix]),
                    server.name) is not None
197072
def get_file_unauth(long_name, service_name, file_path)
      # entry point
      url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/dns/#{SafeNet.escape(service_name)}/#{SafeNet.escape(long_name)}/#{SafeNet.escape(file_path)}"

      # api call
      uri = URI(url)
      http = Net::HTTP.new(uri.host, uri.port)
      req = Net::HTTP::Get.new(uri.path)
      res = http.request(req)
      res_headers = {}
      res.response.each_header {|k,v| res_headers[k] = v}
      res.code == "200" ? {"headers" => res_headers, "body" => res.body} : JSON.parse(res.body)
    end
155366
function performGssapiCanonicalizeHostName(canonicalizeHostName, host, callback) {
      if (!canonicalizeHostName) return callback();

      // Attempt to resolve the host name
      dns.resolveCname(host, (err, r) => {
        if (err) return callback(err);

        // Get the first resolve host id
        if (Array.isArray(r) && r.length > 0) {
          self.host = r[0];
        }

        callback();
      });
    }
1140990
def _populate_domain(self):
        '''
        '''

        self.domain = {}
        for device in self.devices:
            device_name = get_device_info(device).name
            ca_devices = \
                device.tm.cm.trust_domains.trust_domain.load(
                    name='Root'
                ).caDevices
            self.domain[device_name] = [
                d.replace('/%s/' % self.partition, '') for d in ca_devices
            ]