sitemap_gen.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:pymotw3 作者: reingart 项目源码 文件源码
def _MungeLocationListIntoFiles(self, urllist):
    """Given a list of URLs, munge them into our self._pathlist property.
    We do this by assuming all the files live in the same directory as
    the first file in the existing pathlist.  That is, we assume a
    Sitemap index points to Sitemaps only in the same directory.  This
    is not true in general, but will be true for any output produced
    by this script.
    """
    assert self._pathlist
    path = self._pathlist[0]
    path = os.path.normpath(path)
    dir  = os.path.dirname(path)
    wide = False
    if type(path) == types.UnicodeType:
      wide = True

    for url in urllist:
      url = URL.Canonicalize(url)
      output.Log('Index points to Sitemap file at: %s' % url, 2)
      (scheme, netloc, path, query, frag) = urlparse.urlsplit(url)
      file = os.path.basename(path)
      file = urllib.unquote(file)
      if wide:
        file = encoder.WidenText(file)
      if dir:
        file = dir + os.sep + file
      if file:
        self._pathlist.append(file)
        output.Log('Will attempt to read Sitemap file: %s' % file, 1)
  #end def _MungeLocationListIntoFiles
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号