本文整理汇总了Python中Misc.unistrip方法的典型用法代码示例。如果您正苦于以下问题:Python Misc.unistrip方法的具体用法?Python Misc.unistrip怎么用?Python Misc.unistrip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Misc
的用法示例。
在下文中一共展示了Misc.unistrip方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _set_keyword
# 需要导入模块: import Misc [as 别名]
# 或者: from Misc import unistrip [as 别名]
def _set_keyword(self, keyword):
# Make sure parenthesis characters are not allowed in Keywords
if (string.find(keyword, '(') > -1) or (string.find(keyword, ')') > -1):
keyword = string.replace(keyword, '(', '')
keyword = string.replace(keyword, ')', '')
if 'unicode' in wx.PlatformInfo:
# Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
prompt = unicode(_('Keywords cannot contain parenthesis characters.\nYour Keyword has been renamed to "%s".'), 'utf8') % keyword
else:
prompt = _('Keywords cannot contain parenthesis characters.\nYour Keyword has been renamed to "%s".') % keyword
dlg = Dialogs.ErrorDialog(None, prompt)
dlg.ShowModal()
dlg.Destroy()
self._keyword = Misc.unistrip(keyword)
示例2: _set_keywordGroup
# 需要导入模块: import Misc [as 别名]
# 或者: from Misc import unistrip [as 别名]
def _set_keywordGroup(self, keywordGroup):
# ALSO SEE Dialogs.add_kw_group_ui(). The same errors are caught there.
# Make sure parenthesis characters are not allowed in Keyword Group. Remove them if necessary.
if (string.find(keywordGroup, '(') > -1) or (string.find(keywordGroup, ')') > -1):
keywordGroup = string.replace(keywordGroup, '(', '')
keywordGroup = string.replace(keywordGroup, ')', '')
if 'unicode' in wx.PlatformInfo:
# Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
prompt = unicode(_('Keyword Groups cannot contain parenthesis characters.\nYour Keyword Group has been renamed to "%s".'), 'utf8') % keywordGroup
else:
prompt = _('Keyword Groups cannot contain parenthesis characters.\nYour Keyword Group has been renamed to "%s".') % keywordGroup
dlg = Dialogs.ErrorDialog(None, prompt)
dlg.ShowModal()
dlg.Destroy()
# Colons are not allowed in Keyword Groups. Remove them if necessary.
if keywordGroup.find(":") > -1:
keywordGroup = keywordGroup.replace(':', '')
if 'unicode' in wx.PlatformInfo:
msg = unicode(_('You may not use a colon (":") in the Keyword Group name. Your Keyword Group has been changed to\n"%s"'), 'utf8')
else:
msg = _('You may not use a colon (":") in the Keyword Group name. Your Keyword Group has been changed to\n"%s"')
dlg = Dialogs.ErrorDialog(None, msg % keywordGroup)
dlg.ShowModal()
dlg.Destroy()
# Let's make sure we don't exceed the maximum allowed length for a Keyword Group.
# First, let's see what the max length is.
maxLen = TransanaGlobal.maxKWGLength
# Check to see if we've exceeded the max length
if len(keywordGroup) > maxLen:
# If so, truncate the Keyword Group
keywordGroup = keywordGroup[:maxLen]
# Display a message to the user describing the trunctions
if 'unicode' in wx.PlatformInfo:
# Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
msg = unicode(_('Keyword Group is limited to %d characters. Your Keyword Group has been changed to\n"%s"'), 'utf8')
else:
msg = _('Keyword Group is limited to %d characters. Your Keyword Group has been changed to\n"%s"')
dlg = Dialogs.ErrorDialog(None, msg % (maxLen, keywordGroup))
dlg.ShowModal()
dlg.Destroy()
# Remove white space from the Keyword Group.
self._keywordGroup = Misc.unistrip(keywordGroup)
示例3: _set_id
# 需要导入模块: import Misc [as 别名]
# 或者: from Misc import unistrip [as 别名]
def _set_id(self, id):
self._id = Misc.unistrip(id)