本文整理汇总了Python中zoundry.base.util.text.textutil.getSafeString函数的典型用法代码示例。如果您正苦于以下问题:Python getSafeString函数的具体用法?Python getSafeString怎么用?Python getSafeString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getSafeString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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
示例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)
示例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))
示例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)
示例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$
示例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()) )
示例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$
示例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)
示例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)
示例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
示例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)
示例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()
示例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)
示例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