Example #1
0
 def _checkFilePaths(self, nodeName, attrName):
     eleList = self.mshtmlBodyElement.getElementsByTagName(nodeName)
     for ele in eleList:
         pathValue = getNoneString(ele.getAttribute(attrName))
         if not pathValue:
             continue
         try:
             uri = getUriFromFilePath(pathValue)
             if uri and uri != pathValue:
                 ele.setAttribute(attrName, uri ) #$NON-NLS-1$
         except:
             pass
Example #2
0
 def _checkFilePathAttribute(self, node, attrName):
     fpath = node.getAttribute(attrName)
     uri = getUriFromFilePath(fpath)
     # Hack alert: we don't want to modify any URIs that contain the 
     # special template directory token.
     if uri and not u"__RAVEN_TEMPLATE_DIR__" in uri: #$NON-NLS-1$
         # decode url if it is in unicode 'quoted' (e.g. %20 etc).
         uri = decodeUri(uri)
         # if needed, convert hostname to IDNA.
         uri = encodeIDNA(uri)
         # re-encode to Raven conention i.e. internally, store content as IDNA (hostname) with Unicode paths
         uri = encodeUri(uri)
         node.setAttribute(attrName, uri )
Example #3
0
 def _checkFilePathAttribute(self, node, attrName):
     fpath = node.getAttribute(attrName)
     uri = getUriFromFilePath(fpath)
     # Hack alert: we don't want to modify any URIs that contain the
     # special template directory token.
     if uri and not u"__RAVEN_TEMPLATE_DIR__" in uri:  #$NON-NLS-1$
         # decode url if it is in unicode 'quoted' (e.g. %20 etc).
         uri = decodeUri(uri)
         # if needed, convert hostname to IDNA.
         uri = encodeIDNA(uri)
         # re-encode to Raven conention i.e. internally, store content as IDNA (hostname) with Unicode paths
         uri = encodeUri(uri)
         node.setAttribute(attrName, uri)
Example #4
0
 def _getFileMetaData(self, fileName):
     u"""Returns (url, shortName, absPath, size, schemaDate).""" #$NON-NLS-1$
     url = None
     shortName = None 
     absPath = None
     size = None
     schemaDate = None
     try:
         (shortName, absPath, size, schemaDate) = getFileMetaData(fileName) #@UnusedVariable
         if shortName:
             shortName = convertToUnicode(shortName)
         url = getUriFromFilePath(absPath)        
     except:
         pass
     return (url, shortName, absPath, size, schemaDate)
Example #5
0
 def _getFileMetaData(self, fileName):
     u"""Returns (url, shortName, absPath, size, schemaDate)."""  #$NON-NLS-1$
     url = None
     shortName = None
     absPath = None
     size = None
     schemaDate = None
     try:
         (shortName, absPath, size,
          schemaDate) = getFileMetaData(fileName)  #@UnusedVariable
         if shortName:
             shortName = convertToUnicode(shortName)
         url = getUriFromFilePath(absPath)
     except:
         pass
     return (url, shortName, absPath, size, schemaDate)
Example #6
0
 def insertImageFile(self, parentWindow, imageContext):
     u"""insertImageFile(wxWindow, IZXHTMLEditControlImageContext) -> void
     Shows the File open dialog to display an image.
     """ #$NON-NLS-1$
     file = None
     wildcard = u"Image files|*.gif;*.jpg;*.png;*.jpeg" #$NON-NLS-1$
     dialog = wx.FileDialog(parentWindow, u"Choose an image file.", u"", u"", wildcard, wx.OPEN) #$NON-NLS-4$ #$NON-NLS-3$ #$NON-NLS-2$ #$NON-NLS-1$
     if dialog.ShowModal() == wx.ID_OK:
         file = getNoneString(dialog.GetPath())
     dialog.Destroy()
     if file:
         (shortName, absPath, size, schemaDate) = getFileMetaData(file) #@UnusedVariable
         if shortName:
             shortName = convertToUnicode(shortName)
         else:
             shortName = u"" #$NON-NLS-1$
         url = getUriFromFilePath(absPath)                    
         attrs = { u"src" : url, u"alt" : shortName} #$NON-NLS-1$ #$NON-NLS-2$
         imageContext.insertImage(attrs)
 def validateHtml(self, html, izXhtmlValidationListener=None):
     dtdUri = getUriFromFilePath( self.getDtdFilename() )
     html = ZXhtmlDtDValidator.XHTML_TEMPLATE % (dtdUri, html)
     return self._validate(html, 2, izXhtmlValidationListener)
Example #8
0
 def _checkFilePathAttribute(self, node, attrName):
     fpath = node.getAttribute(attrName)
     uri = getUriFromFilePath(fpath)
     if uri:
         uri = encodeIDNA(uri)
         node.setAttribute(attrName, uri )
Example #9
0
 def validateHtml(self, html, izXhtmlValidationListener=None):
     dtdUri = getUriFromFilePath(self.getDtdFilename())
     html = ZXhtmlDtDValidator.XHTML_TEMPLATE % (dtdUri, html)
     return self._validate(html, 2, izXhtmlValidationListener)
Example #10
0
 def _checkFilePathAttribute(self, node, attrName):
     fpath = node.getAttribute(attrName)
     uri = getUriFromFilePath(fpath)
     if uri:
         uri = encodeIDNA(uri)
         node.setAttribute(attrName, uri)