Given a list of subdomains, return the main domain of them
            If the subdomain are across multiple domain, then we cannot have a single website
            it should be splitted
172677
def get_main_domain(self, website):
        
        subdomains = website['subdomains']
        main_domains = set()
        for sub in subdomains:
            for d in self._domains:
                if sub == d or sub.endswith("." + d):
                    main_domains.add(d)
        if len(main_domains) > 1:
            logger.error(
                "The secure site %s cover multiple domains, it should be splitted" % website['name']
            )
            exit(1)
        elif not main_domains:
            logger.error("We cannot find the main domain for %s" % website['name'])
        return list(main_domains)[0]
250487
def del_cached_domain(domains):
    '''
    
    '''
    cache = salt.cache.Cache(__opts__, syspaths.CACHE_DIR)
    if isinstance(domains, six.string_types):
        domains = domains.split(',')
    if not isinstance(domains, list):
        raise CommandExecutionError(
            'You must pass in either a string containing one or more domains '
            'separated by commas, or a list of single domain strings'
        )
    success = []
    failed = []
    for domain in domains:
        try:
            cache.flush('venafi/domains', domain)
            success.append(domain)
        except CommandExecutionError:
            failed.append(domain)
    return {'Succeeded': success, 'Failed': failed}
282273
def get_domain(self):
        
        if self.domain is None:
            return np.array([self.points.min(axis=0), 
                             self.points.max(axis=0)])
        return self.domain
269129
def get_url_directory_string(url):
        
        domain = UrlExtractor.get_allowed_domain(url)

        splitted_url = url.split('/')

        # the following commented list comprehension could replace
        # the following for, if not and break statement
        # index = [index for index in range(len(splitted_url))
        #          if not re.search(domain, splitted_url[index]) is None][0]
        for index in range(len(splitted_url)):
            if not re.search(domain, splitted_url[index]) is None:
                if splitted_url[-1] is "":
                    splitted_url = splitted_url[index + 1:-2]
                else:
                    splitted_url = splitted_url[index + 1:-1]
                break

        return '_'.join(splitted_url)
1179957
def get_all_subdomains(offset=None, count=None, min_sequence=None, db_path=None, zonefiles_dir=None):
    
    opts = get_blockstack_opts()
    if not is_subdomains_enabled(opts):
        return []

    if db_path is None:
        db_path = opts['subdomaindb_path']

    if zonefiles_dir is None:
        zonefiles_dir = opts['zonefiles']

    db = SubdomainDB(db_path, zonefiles_dir)
    return db.get_all_subdomains(offset=offset, count=count, min_sequence=None)
560421
def subdomain(self, index, value=None):
        
        if value is not None:
            subdomains = self.subdomains()
            subdomains[index] = value
            return URL._mutate(self, host='.'.join(subdomains))
        return self.subdomains()[index]
1344931
def get_domains(self):
        
        if self.domains is None:
            self.domains = list(
                set(self.source.get_domains() + self.target.get_domains()))
        return self.domains
476667
def get_domain_name(url):
    
    if not url.startswith("http"):
        url = "http://" + url
    if not is_valid_url(url):
        raise ValueError("Invalid URL '%s'" % url)
    parse = urlparse(url)
    return parse.netloc
1006222
def parse_domain(url):
    
    domain_match = lib.DOMAIN_REGEX.match(url)
    if domain_match:
        return domain_match.group()
1227273
def host_domains(self, ip=None, limit=None, **kwargs):
        """"""
        return self._results('reverse-ip', '/v1/{0}/host-domains'.format(ip), limit=limit, **kwargs)
658972
def get_domain_url(url):
    
    if "http://" not in url and "https://" not in url:
        return url
    url_header = url.split('://')[0]
    simple_url = url.split('://')[1]
    base_url = simple_url.split('/')[0]
    domain_url = url_header + '://' + base_url
    return domain_url
539758
def rpc_get_all_subdomains( self, offset, count, **conf_info):
        
        if not check_offset(offset):
            return {'error': 'invalid offset', 'http_status': 400}

        if not check_count(count, 100):
            return {'error': 'invalid count', 'http_status': 400}

        all_subdomains = get_all_subdomains(offset = offset,
                                            count = count)

        return self.success_response( {'names': all_subdomains} )
243050
def get_DID_subdomain(self, did, cur=None):
        
        did = str(did)

        try:
            did_info = parse_DID(did)
            assert did_info['name_type'] == 'subdomain', 'Not a subdomain DID'
        except:
            raise ValueError("Invalid DID: {}".format(did))
        
        original_address = did_info['address']
        name_index = did_info['index']

        # find the initial subdomain (the nth subdomain created by this address)
        cmd = 'SELECT fully_qualified_subdomain FROM {} WHERE owner = ? AND sequence = ? ORDER BY parent_zonefile_index, zonefile_offset LIMIT 1 OFFSET ?;'.format(self.subdomain_table)
        args = (original_address, 0, name_index)

        cursor = None
        if cur is None:
            cursor = self.conn.cursor()
        else:
            cursor = cur

        subdomain_name = None

        rows = db_query_execute(cursor, cmd, args)
        for r in rows:
            subdomain_name = r['fully_qualified_subdomain']
            break

        if not subdomain_name:
            raise SubdomainNotFound('Does not correspond to a subdomain: {}'.format(did))

        # get the current form
        subrec = self.get_subdomain_entry(subdomain_name, cur=cur)
        subrec.did_info = did_info
        return subrec
478955
def get_domain(self):
        
        points = np.vstack([place.get_domain() for place in self])
        return np.array([points.min(axis=0), points.max(axis=0)])
104271
def get_domain(self, value):
        
        return [k for k, v in self.all if v == value]
932547
def is_subdomain(domain, reference):
    
    index_of_reference = domain.find(reference)
    if index_of_reference > 0 and domain[index_of_reference:] == reference:
        return True
    return False
529316
def is_not_from_subdomain(self, response, site_dict):
        

        root_url = re.sub(re_url_root, '', site_dict["url"])
        return UrlExtractor.get_allowed_domain(response.url) == root_url