当前位置: 首页>>代码示例>>Python>>正文


Python Path.setSalt方法代码示例

本文整理汇总了Python中exe.engine.path.Path.setSalt方法的典型用法代码示例。如果您正苦于以下问题:Python Path.setSalt方法的具体用法?Python Path.setSalt怎么用?Python Path.setSalt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在exe.engine.path.Path的用法示例。


在下文中一共展示了Path.setSalt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import setSalt [as 别名]
 def __init__(self, baseurl, node, client=None):
     self.baseurl = baseurl.decode(sys.getfilesystemencoding())
     self.node = node
     self.client = client
     self.numdirs = 0
     resources = {}
     resources['mimes'] = {}
     resources['urls'] = {}
     
     url = Url(self.baseurl, self.baseurl)
     url.createNode(node, _('Contents of directory'))
     resources['urls'][url.relpath] = url
     try:
         for root, dirs, files in self._safewalk(self.baseurl):
             if self.cancel:
                 return
             self.numdirs += 1
     except UnicodeDecodeError:
         raise
     i = 1
     for root, dirs, files in self._safewalk(self.baseurl):
         html = u""
         idevice = None
         if self.client:
             self.client.call('eXe.app.getController("Toolbar").updateImportProgressWindow',_(u'Analizing directory %d of %d: %s') % (i, self.numdirs,root.encode(sys.getfilesystemencoding())))
         for dir in dirs:
             if self.cancel:
                 return
             path = root + os.path.sep + dir
             url = Url(path, self.baseurl)
             url.createNode(resources['urls'][url.parentpath].node)
             resources['urls'][url.relpath] = url
         for file in files:
             if self.cancel:
                 return
             path = root + os.path.sep + file
             url = Url(path, self.baseurl)
             parent = resources['urls'][url.parentpath]
             if not idevice:
                 idevice = parent.createIdevice()
             try:
                 p = Path(path)
                 p.setSalt(str(url))
                 r = Resource(idevice,p)
             except:
                 continue
             url.href = 'resources/%s' % (quote(r.storageName))
             html += u"<p><a href=%s>%s</p>\n" % (url.href,url.basename)
             resources['urls'][url.relpath] = url
             if url.mime in resources['mimes'].keys():
                 resources['mimes'][url.mime].append(url)
             else:
                 resources['mimes'][url.mime] = [ url ]
         if idevice:
             idevice.setContent(html)
         i += 1
     self.resources = resources
开发者ID:Rafav,项目名称:iteexe,代码行数:59,代码来源:scanresources.py

示例2: _insertNode

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import setSalt [as 别名]
    def _insertNode(self, node, url, depth=0, idevice=None):
        if self.cancel:
            return
        if isinstance(url,str):
            link = None
            url = self.resources['urls'][url]
        elif isinstance(url,Link):
            link = url
            url = link.url

        if url.mime == 'text/html' and self.depths[str(url)] >= depth:
            if self.client:
                self.client.call('eXe.app.getController("Toolbar").updateImportProgressWindow',_(u'Inserting %s') % (str(url)))
            
            type = link.tag.name if link and link.tag else 'a'
            if type not in ['frame','iframe'] and node:
                node = node.createChild()
                node.setTitle(self._guessName(url))
                if depth == 1:
                    node.up()
            if not node:
                node = self.node
            parent = idevice if type in ['frame','iframe'] else None
            idevice = FreeTextIdevice(type=type,parent=parent)
            idevice.edit = False
            node.addIdevice(idevice)
        
        if url.type == "file":
            p = Path(self.baseurl + os.path.sep + str(url))
            p.setSalt(str(url))
            r = Resource(idevice,p)
            url.storageName = quote(r.storageName)
            if link and link.relative not in link.referrer.contentUpdated:
                if link.match:
                    link.referrer.content = link.referrer.content.replace(link.match,'###resources###/%s' % (url.storageName))                    
                else:
                    link.referrer.content = link.referrer.content.replace(link.relative,'###resources###/%s' % (url.storageName))
                link.referrer.contentUpdated.append(link.relative)

        if self.depths[str(url)] < depth:
            return        

        for l in url.links:
            if self.cancel:
                return
            self._insertNode(node, l, depth+1, idevice)
        
        content = url.getContent()
        if content:
            content_w_resourcePaths = re.sub('###resources###/','resources/',content)
            content_wo_resourcePaths = re.sub('###resources###/','',content) 
            if url.mime == "text/html" and idevice:
                soup = url.getSoup()
                if soup and soup.declaredHTMLEncoding:
                    content_w_resourcePaths = re.sub(soup.declaredHTMLEncoding,'utf-8',content_w_resourcePaths,re.IGNORECASE)
                    content_wo_resourcePaths = re.sub(soup.declaredHTMLEncoding,'utf-8',content_wo_resourcePaths,re.IGNORECASE)
                if soup and soup.find('frameset'):
                    idevice.type = 'frameset'
                idevice.setContent(content_w_resourcePaths,content_wo_resourcePaths)
            f = open(r.path,"w")
            f.write(content_wo_resourcePaths.encode('utf-8'))
            f.close()
开发者ID:Rafav,项目名称:iteexe,代码行数:64,代码来源:scanresources.py


注:本文中的exe.engine.path.Path.setSalt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。