• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python textutil.getSafeString函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中zoundry.base.util.text.textutil.getSafeString函数的典型用法代码示例。如果您正苦于以下问题:Python getSafeString函数的具体用法?Python getSafeString怎么用?Python getSafeString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _populateAtomEntry

    def _populateAtomEntry(self, atomEntry, zserverBlogEntry):
        title = getSafeString( zserverBlogEntry.getTitle() )
        content = getSafeString( self._formatContentForPublishing( zserverBlogEntry ) )
        utcDateTime = zserverBlogEntry.getUtcDateTime()
        draft = zserverBlogEntry.isDraft()
        author = getNoneString( zserverBlogEntry.getAuthor() )
        if not author:
            author = self.getUsername()

        atomEntry.setTitle(title)
        atomEntry.setDate(utcDateTime)
        atomEntry.setContent(content)
        atomEntry.setDraft(draft)
        atomEntry.setAuthor(author)

        atomCatList = []
        # list of categories already added
        catNames = []
        for cat in zserverBlogEntry.getCategories():
            # map Zoundry cat id to atom category 'term' attribute.
            atomCat = ZAtomCategory(cat.getId(), cat.getName() )
            atomCatList.append( atomCat )
            name = cat.getName().lower()
            if name not in catNames:
                catNames.append(name)
        # Special case for Blogger. Blend zcategories + ztags into atom catories
        # FIXME (PJ) externalize this to a capability or param
        if zserverBlogEntry.getTagwords() and self.getApiUrl().startswith(u"http://www.blogger.com/feeds/default/blogs"): #$NON-NLS-1$
            for tagword in zserverBlogEntry.getTagwords():
                if tagword.lower() not in catNames:
                    catid = tagword
                    atomCat = ZAtomCategory(catid, tagword )
                    atomCatList.append( atomCat )

        atomEntry.setCategories(atomCatList)
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:35,代码来源:atomapi.py


示例2: ping

    def ping(self, pingUrl, id, url, title, blogName, excerpt):
        u"""ping(string, string, string, string, string, string) -> ZTrackbackPingResponse
        Pings the track back and returns ZTrackbackPingResponse""" #$NON-NLS-1$
        if getNoneString(pingUrl) is None:
            return ZTrackbackPingResponse(False, u"Trackback ping url is required.") #$NON-NLS-1$

        if getNoneString(id) is None:
            return ZTrackbackPingResponse(False, u"Trackback Originating Resource ID is required.") #$NON-NLS-1$

        if getNoneString(url) is None:
            return ZTrackbackPingResponse(False, u"Trackback post url is required.") #$NON-NLS-1$

        title = convertToUtf8( getSafeString(title) )
        blogName = convertToUtf8( getSafeString(blogName))
        excerpt = convertToUtf8( getSafeString(excerpt))

        postData = {
            u'id': id, #$NON-NLS-1$
            u'url': url, #$NON-NLS-1$
            u'title': title, #$NON-NLS-1$
            u'blog_name': blogName, #$NON-NLS-1$
            u'excerpt': excerpt #$NON-NLS-1$
        }

        htmlResult = self._sendHttpPostData(pingUrl, postData)
        resp = self._parseResponse(htmlResult)
        return resp
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:27,代码来源:trackback.py


示例3: setPubMetaData

    def setPubMetaData(self, pubMetaData):
        # Updates the UI controls based on the data in pubMetaData
        self.draftCB.SetValue(pubMetaData.isPublishAsDraft())
        pubTime = pubMetaData.getPublishTime()
        if pubTime is not None:
            self.overridePubTimeCB.SetValue(True)
            self.dateCtrl.Enable(True)
            self.dateCtrl.setDateTime(pubTime)
        self.thumbnailsOnlyCB.SetValue(pubMetaData.isUploadTNsOnly())
        self.forceUploadCB.SetValue(pubMetaData.isForceReUploadImages())
        self.lightboxCB.SetValue(pubMetaData.isAddLightbox())
        self.poweredByZoundryCB.SetValue(pubMetaData.isAddPoweredBy())

        # WP custom data
        slug = getSafeString( getCustomWPMetaDataAttribute(pubMetaData, u"wp_slug") ) #$NON-NLS-1$
        self.wpPostSlugTextCtrl.SetValue(slug)
        # WP password
        s = getSafeString( getCustomWPMetaDataAttribute(pubMetaData, u"wp_password") ) #$NON-NLS-1$
        self.wpPasswordTextCtrl.SetValue(s)

        # WP pub status
        self.wpPublishStatusValue = ZPubMetaDataView.WP_PUBLISHED
        s = getSafeString( getCustomWPMetaDataAttribute(pubMetaData, u"post_status") ) #$NON-NLS-1$

        if s == u"pending":  #$NON-NLS-1$
            self.wpPublishStatusValue = ZPubMetaDataView.WP_PENDING
        elif s == u"private":  #$NON-NLS-1$
            self.wpPublishStatusValue = ZPubMetaDataView.WP_PRIVATE
        elif s == u"draft" or pubMetaData.isPublishAsDraft():  #$NON-NLS-1$
            self.wpPublishStatusValue = ZPubMetaDataView.WP_DRAFT

        self.wpPubStatusCombo.SetSelection(self.wpPublishStatusValue)
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:32,代码来源:pubdatawidgets.py


示例4: _populateWidgets

 def _populateWidgets(self):
     username = self._getSession().getAccountUsername()
     password = self._getSession().getAccountPassword()
     endpoint = self._getSession().getAccountAPIUrl()
     self.username.SetValue(getSafeString(username))
     self.password.SetValue(getSafeString(password))
     self.endpoint.SetValue(getSafeString(endpoint))
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:7,代码来源:settingssubpage.py


示例5: getProxyConfig

 def getProxyConfig(self):
     enabled = False
     host = u""  #$NON-NLS-1$
     port = u""  #$NON-NLS-1$
     try:
         handle = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, u"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings") #$NON-NLS-1$
         (enableStr, type) = _winreg.QueryValueEx(handle, u"ProxyEnable") #$NON-NLS-1$
         _winreg.CloseKey(handle)
         enableStr = getSafeString(enableStr)
         enabled = enableStr == u"1" #$NON-NLS-1$
     except:
         pass
             
     try:
         handle = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, u"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings") #$NON-NLS-1$
         (hostsStr, type) = _winreg.QueryValueEx(handle, u"ProxyServer") #$NON-NLS-1$
         _winreg.CloseKey(handle)
         entries = getSafeString(hostsStr).split(u";") # eg http=127.0.0.1:8888; https=127.0.0.1:8888  #$NON-NLS-1$
         regHostportStr = None # host:port value, if available from registry.
         if len(entries) > 0:
             for entry in entries:
                 # entry = 'scheme=host:port
                 entry = entry.strip()
                 (scheme, regHostportStr) = entry.split(u"=") #$NON-NLS-1$
                 if scheme == u"http": #$NON-NLS-1$
                     break 
         if regHostportStr:
             hp = regHostportStr.strip().split(u":")  #$NON-NLS-1$
             if len(hp) > 0:
                 host = hp[0].strip()
             if len(hp) > 1:
                 port = hp[1].strip()
     except:
         pass 
     return ZOSProxyConfig(ZOSProxyConfig.TYPE_HTTP, enabled, host, port)
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:35,代码来源:win32.py


示例6: getRowText

 def getRowText(self, rowIndex, columnIndex):
     if len(self.blogList) > 0 and rowIndex < len(self.blogList):
         blog = self.blogList[rowIndex]
         if columnIndex == 0:
             return getSafeString(blog.getName())
         elif columnIndex == 1:
             return getSafeString(blog.getUrl())
     return u"NA-r%d-c%d" % (rowIndex, columnIndex) #$NON-NLS-1$
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:8,代码来源:publisher.py


示例7: _populateContentWidgets

    def _populateContentWidgets(self):
        if self.model.isInsertMode():
            self.rowsText.SetValue( str(self.model.getRows()) )
            self.colsText.SetValue( str(self.model.getCols()) )

        self.borderText.SetValue( getSafeString(self.model.getBorder()) )
        self.paddingText.SetValue( getSafeString(self.model.getPadding()) )
        self.spacingText.SetValue( getSafeString(self.model.getSpacing()) )
        self.widthText.SetValue( getSafeString( self.model.getWidth()) )
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:9,代码来源:tabledialog.py


示例8: _populateNonHeaderWidgets

    def _populateNonHeaderWidgets(self):
        self.urlText.SetValue( getSafeString( self.model.getAttribute(u"href") ) ) #$NON-NLS-1$
        self.titleText.SetValue( getSafeString( self.model.getAttribute(u"title") ) ) #$NON-NLS-1$
        self.targetText.SetValue( getSafeString( self.model.getAttribute(u"target") ) ) #$NON-NLS-1$
        self.newWindowCB.SetValue( self.model.isOpenInNewWindow() )
        self.classText.SetValue( getSafeString( self.model.getAttribute(u"class") ) ) #$NON-NLS-1$
        self.relText.SetValue( getSafeString( self.model.getAttribute(u"rel") ) ) #$NON-NLS-1$

        if not self.model.isEditMode() and not self.urlText.GetValue():
            self.urlText.SetValue(u'http://') #$NON-NLS-1$
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:10,代码来源:linkdialog.py


示例9: _getImageSizeFromElem

 def _getImageSizeFromElem(self):
     width = -1
     try:
         width = int( getSafeString( self.element.getAttribute(u"width")) )#$NON-NLS-1$
     except:
         pass
     height = -1
     try:
         height = int( getSafeString( self.element.getAttribute(u"height")) )#$NON-NLS-1$
     except:
         pass
     return (width, height)
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:12,代码来源:pubuploadhandler.py


示例10: apply

 def apply(self):
     # also set changes to the global value
     (h, p) = self._getHostPortFromUI()
     proxy = ZHttpProxyConfiguration()
     proxy.setEnable( self.enableCB.GetValue() )
     proxy.setHost( h )
     port = 8080
     try:
         port  = int( p )
     except:
         pass
     proxy.setPort( port )
     proxy.setProxyAuthorization( getSafeString(self.usernameTxt.GetValue()), getSafeString(self.passwordTxt.GetValue()) )
     return ZApplicationPreferencesPrefPage.apply(self)
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:14,代码来源:proxyprefpage.py


示例11: _getAlbumName

    def _getAlbumName(self):
        if u"albumName" in self.properties: #$NON-NLS-1$
            return getSafeString(self.properties[u"albumName"]) #$NON-NLS-1$
        return None
    # end _getAlbumName()

# end ZLJFotoBilderStorageProvider
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:7,代码来源:ljfotobilderprovider.py


示例12: setInitDocument

    def setInitDocument(self, document):
        u"""setInitDocument(IZBlogDocument) -> void
        Copies the document data to the model.""" #$NON-NLS-1$
        # Initialize the model data  with the given document
        title = getSafeString(document.getTitle())
        self.setTitle(title)

        self.setTagwords(u"") #$NON-NLS-1$
        # get tagwords based on default NS
        iZTagwordsObj = document.getTagwords(IZBlogPubTagwordNamespaces.DEFAULT_TAGWORDS_URI)
        if not iZTagwordsObj:
            # legacy, pre alpha build 132 support. check technorati ns. # FIXME (PJ) remove technorati tags NS for final release
            iZTagwordsObj = document.getTagwords(u"http://technorati.com/tag/") #$NON-NLS-1$
        if iZTagwordsObj:
            self.setTagwords( iZTagwordsObj.getValue() )

        # Use any existing pub meta data if it exists, else fall back to
        # blog info list data.
        pubMetaDataList = document.getPubMetaDataList()
        if pubMetaDataList is None or len(pubMetaDataList) == 0:
            pubMetaDataList = []
            # create pub meta data from blog info list.
            blogInfoList = document.getBlogInfoList()
            if blogInfoList is not None and len(blogInfoList) > 0:
                for blogInfo in blogInfoList:
                    pubMetaData = self._createPubMetaData(blogInfo)
                    pubMetaDataList.append(pubMetaData)

        if pubMetaDataList is not None:
            self.setPubMetaDataList(pubMetaDataList)
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:30,代码来源:blogeditormodel.py


示例13: _applyListMarkup

    def _applyListMarkup(self, listTag):
        handleLocallly = False
        tr = self.getSelectedTextRange()
        if tr:
            ele = tr.parentElement()
            if ele and tr.text == ele.innerText and ele.tagName != u"BODY": #$NON-NLS-1$
                pass 
            elif ele and ele.outerHTML == tr.htmlText:
                pass
            else:
                html = tr.htmlText.strip(u"\n\r\ ") #$NON-NLS-1$
                # handle locally if selection is a text fragment (i.e does not have <P> etc)
                handleLocallly = html and html[0] != u"<" #$NON-NLS-1$

        if handleLocallly: 
            # listTag = ou | ul on a text selection (instead of whole para)
            listTag = getSafeString(listTag).lower()
            if listTag not in (u"ol", u"ul"): #$NON-NLS-1$ #$NON-NLS-2$
                listTag = u"ul" #$NON-NLS-1$
            openTag = u"<%s><li>" % listTag #$NON-NLS-1$
            closeTag = u"</li></%s>" % listTag #$NON-NLS-1$
            self._wrapSelection(openTag, closeTag)
            
        elif listTag in (u"ol", u"ul"): #$NON-NLS-1$ #$NON-NLS-2$
            # Let IE handle it. IE will take care of handling multiple paras into a multline bullet
            if listTag == u"ol":             #$NON-NLS-1$
                ZMSHTMLControlBase.execCommand(self, u"InsertOrderedList", None) #$NON-NLS-1$
            else:
                ZMSHTMLControlBase.execCommand(self, u"InsertUnOrderedList", None) #$NON-NLS-1$
            # Assume exec command modifies the document.
            self._fireContentModified()            
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:31,代码来源:mshtmlcontrol.py


示例14: _createLabelFromProperty

 def _createLabelFromProperty(self, siteProp):
     label = getSafeString(siteProp.getDisplayName())
     if siteProp.getType() == u"checkbox": #$NON-NLS-1$
         label = u"" #$NON-NLS-1$
     else:
         label = label + u":" #$NON-NLS-1$
     return wx.StaticText(self, wx.ID_ANY, label)
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:7,代码来源:editstoredialog.py


示例15: getMisspelledWordData

    def getMisspelledWordData(self, spellCheckResult):
        u"""getMisspelledWordData(IZSpellCheckResult) -> (string, int, int)
        Returns tuple (misspelled_sentence, startPos, endPos) based on the current result.
        The misspelled_sentence includes the misspelled word and any surrounding words.
        startPos and endPos are the character position of the misspelled word within
        the misspelled_sentence.
        """ #$NON-NLS-1$
        sentence = u"" #$NON-NLS-1$
        startPos = 0
        endPos = 0
        if spellCheckResult:
            try:
                if spellCheckResult.getWordContext():
                    sentence = spellCheckResult.getWordContext()
                    (startPos, endPos) = spellCheckResult.getRangeInContext()
                else:
                    sentence = getSafeString( spellCheckResult.getWord() ).strip()
                    endPos = len(sentence)
            except:
                pass
        #
        return (sentence, startPos, endPos)
    # end getMisspelledWordData()

# end ZSpellCheckModel
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:25,代码来源:spellcheckmodel.py


示例16: _getHandlerClass

 def _getHandlerClass(self, scheme):
     clazz = None
     scheme = getSafeString(scheme).lower()
     for (tmpScheme, tmpClazz) in self.handlerClases: #@UnusedVariable
         if tmpScheme == scheme:
             clazz = tmpClazz
             break
     return clazz
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:8,代码来源:authhandlers.py


示例17: onDataChanged

 def onDataChanged(self, event):
     if self.enableCB.GetValue():
         (h, p) = self._getHostPortFromUI()
         self.session.setUserPreference(IZAppUserPrefsKeys.PROXY_HOST, h)
         self.session.setUserPreference(IZAppUserPrefsKeys.PROXY_PORT, p)
         self.session.setUserPreference(IZAppUserPrefsKeys.PROXY_USERNAME, getSafeString(self.usernameTxt.GetValue()))
         self.onSessionChange()            
     event.Skip()
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:8,代码来源:proxyprefpage.py


示例18: _getHostPortFromUI

 def _getHostPortFromUI(self):        
     host = getSafeString( self.hostTxt.GetValue() )
     port = getSafeString( self.portTxt.GetValue() )
     if host.lower().startswith(u"http"): #$NON-NLS-1$
         (scheme, netloc, path, query, fragment) = urlsplit(host, u"http") #$NON-NLS-1$ @UnusedVariable
         desHostPort = netloc.split(u":") #$NON-NLS-1$
         h = desHostPort[0]
         p = u"80" #$NON-NLS-1$
         if len(desHostPort) == 2:
             p = desHostPort[1]
         if scheme == u"ssl" and p == u"80": #$NON-NLS-1$ #$NON-NLS-2$
             p = u"443" #$NON-NLS-1$
         if h:
             host = h
         if not port and p:
             port = p
     return (host, port)
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:17,代码来源:proxyprefpage.py


示例19: createXhtmlDocument

 def createXhtmlDocument(self):
     u"""createXhtmlDocument() -> ZXhtmlDocument""" #$NON-NLS-1$
     file = getSafeString( self.izBlogThisInformation.getFile() )
     xhtmlDom = None
     if os.path.exists(file):
         try:
             xhtmlDom = loadXhtmlDocumentFromFile(file)
             return xhtmlDom
         except:
             pass
     # create new doc since file content was not found
     title = getSafeString( self.izBlogThisInformation.getTitle() )
     htmlString = u"<html><head><title>%s</title></head><body></body></html>" % title #$NON-NLS-1$
     xhtmlDoc = loadXhtmlDocumentFromString(htmlString)
     bodyNode = xhtmlDoc.getBody()
     self._createXhtmlContent(bodyNode)
     return xhtmlDoc
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:17,代码来源:blogthishandler.py


示例20: __init__

 def __init__(self, term, label = None, scheme = None):
     self.term = term
     self.label = label
     self.scheme = scheme
     name = getNoneString(label)
     if not name:
         name = getSafeString(term)
     ZServerBlogCategory.__init__(self, term, name)
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:8,代码来源:atomapi.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python dom.ZDom类代码示例发布时间:2022-05-26
下一篇:
Python textutil.getNoneString函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap