コード例 #1
0
	def check(self, value):
		# Only ascii chars allowed in these keys
		value = BaseString.check(self, value)
		if isinstance(value, unicode) \
		and value.encode('utf-8') != value:
			raise ValueError, 'ASCII string required'
		return value
コード例 #2
0
ファイル: applications.py プロジェクト: hjq300/zim-wiki
	def check(self, value):
		# Only ascii chars allowed in these keys
		value = BaseString.check(self, value)
		if isinstance(value, unicode) \
		and value.encode('utf-8') != value:
			raise ValueError, 'ASCII string required'
		return value
コード例 #3
0
 def check(self, value):
     # Only ascii chars allowed in these keys
     value = BaseString.check(self, value)
     if isinstance(value, str):
         try:
             x = value.encode('ascii')
         except UnicodeEncodeError:
             raise ValueError('ASCII string required')
         else:
             pass
     return value