Return whether the file is likely a Sitemap.
964737
def is_file(cls, file):
        ''''''
        peeked_data = wpull.util.peek_file(file)

        if is_gzip(peeked_data):
            try:
                peeked_data = wpull.decompression.gzip_uncompress(
                    peeked_data, truncated=True
                )
            except zlib.error:
                pass

        peeked_data = wpull.string.printable_bytes(peeked_data)

        if b'<?xml' in peeked_data \
           and (b'<sitemapindex' in peeked_data or b'<urlset' in peeked_data):
            return True
46721
def parse(self, filename):
        
        with io.open(filename, 'r', encoding='utf-8') as _:
            lines = _.readlines()

        all_source_files = set()
        source_map = {}

        lineno = 0
        root = None
        index = None
        cur_level = -1
        parent_queue = []

        for line in lines:
            try:
                level, line = dedent(line)
                if line.startswith('#'):
                    lineno += 1
                    continue
                elif line.startswith('\\#'):
                    line = line[1:]
            except IndentError as exc:
                error('bad-indent', 'Invalid indentation', filename=filename,
                      lineno=lineno, column=exc.column)

            if not line:
                lineno += 1
                continue

            source_file = dequote(line)

            if not source_file:
                lineno += 1
                continue

            if source_file in all_source_files:
                error('sitemap-duplicate', 'Filename listed twice',
                      filename=filename, lineno=lineno, column=level * 8 + 1)

            all_source_files.add(source_file)
            source_map[source_file] = (lineno, level * 8 + 1)

            page = OrderedDict()

            if root is not None and level == 0:
                error('sitemap-error', 'Sitemaps only support one root',
                      filename=filename, lineno=lineno, column=0)

            if root is None:
                root = page
                index = source_file
            else:
                lvl_diff = cur_level - level
                while lvl_diff >= 0:
                    parent_queue.pop()
                    lvl_diff -= 1

                parent_queue[-1][source_file] = page

            parent_queue.append(page)

            cur_level = level

            lineno += 1

        return Sitemap(root, filename, index, source_map)
550009
def index_as_xml(self):
        """"""
        self.default_capability()
        s = self.new_sitemap()
        return s.resources_as_xml(self, sitemapindex=True)
845660
def sitemap(request):
    """"""
    xml = Sitemap()
    author = request.matchdict.get('from_id')
    if author is not None:
        match = "AND '{}' = authors[1]".format(author)
    else:
        match = ''

    with db_connect() as db_connection:
        with db_connection.cursor() as cursor:
            cursor.execute("""SELECT
                    ident_hash(uuid, major_version, minor_version)
                        AS idver,
                    name,
                    revised
                FROM latest_modules
                WHERE portal_type NOT IN ('CompositeModule', 'SubCollection')
                {}
                ORDER BY module_ident DESC""".format(match))
            res = cursor.fetchall()
            for ident_hash, page_name, revised in res:
                #  replace punctuation with whitespace
                page_name = re.sub(NON_WORD, ' ',
                                   page_name.decode('utf-8'), re.UNICODE)
                # remove leading and trailing whitespace
                page_name = page_name.strip().encode('utf-8')
                # replace spaces with dashes
                page_name = re.sub(' +', '-',
                                   page_name.decode('utf-8'), re.UNICODE)
                url = request.route_url('content',
                                        ident_hash=ident_hash,
                                        ignore=u'/{}'.format(page_name))
                if notblocked(url):
                    xml.add_url(url, lastmod=revised)

    resp = request.response
    resp.status = '200 OK'
    resp.content_type = 'text/xml'
    resp.body = xml()
    return resp
1014717
def is_local_url(target):
    """"""
    ref_url = urlparse(cfg.get('CFG_SITE_SECURE_URL'))
    test_url = urlparse(urljoin(cfg.get('CFG_SITE_SECURE_URL'), target))
    return test_url.scheme in ('http', 'https') and \
        ref_url.netloc == test_url.netloc
143038
def check(self, url_data):
        """"""
        location = get_location(url_data.host)
        if location:
            url_data.add_info(_("URL is located in %(location)s.") %
            {"location": _(location)})
1040745
def iwhere( filename ):
    

    possible_paths =      _gen_possible_matches( filename )
    existing_file_paths = filter( os.path.isfile, possible_paths )
    return existing_file_paths
1257835
def is_mdgel(self):
        """"""
        # TODO: this likely reads the second page from file
        try:
            ismdgel = self.pages[0].is_mdgel or self.pages[1].is_mdgel
            if ismdgel:
                self.is_uniform = False
            return ismdgel
        except IndexError:
            return False
279840
def _match_real(filename, include, exclude, follow, symlinks):
    """"""

    sep = '\\' if util.platform() == "windows" else '/'
    if isinstance(filename, bytes):
        sep = os.fsencode(sep)
    if not filename.endswith(sep) and os.path.isdir(filename):
        filename += sep

    matched = False
    for pattern in include:
        if _fs_match(pattern, filename, sep, follow, symlinks):
            matched = True
            break

    if matched:
        matched = True
        if exclude:
            for pattern in exclude:
                if _fs_match(pattern, filename, sep, follow, symlinks):
                    matched = False
                    break
    return matched
565095
public boolean isMatchingCurrentSite(CmsObject cms, CmsSiteMatcher matcher) {

        return m_siteMatcherSites.get(matcher) == getCurrentSite(cms);
    }
329053
def is_template(self, filename):
        
        if self.is_partial(filename):
            return False

        if self.is_ignored(filename):
            return False

        if self.is_static(filename):
            return False

        return True
489862
public void openSiteMap(String sitePath, boolean siteChange) {

        String uri = CmsCoreProvider.get().link(
            CmsCoreProvider.get().getUri()) + "?" + CmsCoreData.PARAM_PATH + "=" + sitePath;
        if (!siteChange) {
            uri += "&" + CmsCoreData.PARAM_RETURNCODE + "=" + getData().getReturnCode();
        }
        Window.Location.replace(uri);
    }
168598
def _islinklike(dir_path):
    '''
    
    '''
    dir_path = ph.path(dir_path)
    if platform.system() == 'Windows':
        if dir_path.isjunction():
            return True
    elif dir_path.islink():
        return True
    return False
580608
static function SitemapCacheFile(Site $site)
    {
        $cacheFolder = Path::Combine(PHINE_PATH, 'App/Phine/Cache/Sitemap');
        $filename = Path::AddExtension($site->GetID(), 'xml');
        return Path::Combine($cacheFolder, $filename);
    }
787897
def is_file(cls, file):
        ''''''
        peeked_data = wpull.string.printable_bytes(
            wpull.util.peek_file(file)).lower()

        if b'<!doctype html' in peeked_data \
           or b'<head' in peeked_data \
           or b'<title' in peeked_data \
           or b'<html' in peeked_data \
           or b'<script' in peeked_data \
           or b'<table' in peeked_data \
           or b'<a href' in peeked_data:
            return True
77024
public boolean hasParameters(String site) {
		SiteParameters siteParameters = siteParamsMap.get(site);
		if (siteParameters == null) {
			return false;
		}
		return siteParameters.hasParams();
	}
7999
def is_pythonw(filename):
    """"""
    pattern = r'.*python(\d\.?\d*)?w(.exe)?$'
    if re.match(pattern, filename, flags=re.I) is None:
        return False
    else:
        return True