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

Python utils.convertToUnicode函数代码示例

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

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



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

示例1: metadata

	def metadata(self):
		d = dict(self.song.metadata)
		for (key,func) in (
			("artist",None),
			("title",None),
			("album",None),
			("duration",utils.formatTime),
			("url",None),
			("rating",None),
			("tags",self._convertTagsToText),
			("gain",self._formatGain),
			("completedCount",None),
			("skipCount",None),
			("lastPlayedDate",utils.formatDate),
			("id",repr),
		):
			try: value = getattr(self.song, key)
			except AttributeError: pass
			else:
				if func: value = func(value)
				if not isinstance(value, (str,unicode)):
					value = str(value)
				d[key] = utils.convertToUnicode(value)
		l = []
		for key,value in sorted(d.items()):
			l += [{"key": key, "value": value}]
		return l
开发者ID:LoweReception,项目名称:music-player,代码行数:27,代码来源:SongEdit.py


示例2: tableView_objectValueForTableColumn_row_

 def tableView_objectValueForTableColumn_row_(self, tableView, tableColumn, rowIndex):
     key = str(tableColumn.identifier())
     v = self.data[rowIndex].get(key, None)
     if key in self.formaters:
         v = self.formaters[key](v)
     if isinstance(v, str):
         v = utils.convertToUnicode(v)
     return v
开发者ID:antback,项目名称:music-player,代码行数:8,代码来源:guiCocoaCommon.py


示例3: handleRowIndex

			def handleRowIndex(index, stop):
				try:
					url = self.data[index].get("url", None)
					if url:
						url = utils.convertToUnicode(url)
						possibleSources.append(url)
				except Exception:
					import sys
					sys.excepthook(*sys.exc_info())						
开发者ID:kingsj,项目名称:music-player,代码行数:9,代码来源:guiCocoaCommon.py


示例4: notifyCurSong

	def notifyCurSong():
		pynotify.init("MusicPlayer")
		song = state.curSong
		s = None
		try:
			s = convertToUnicode(song.userString)
		except: pass

		notif = pynotify.Notification(s)
		notif.show()
开发者ID:BMXE,项目名称:music-player,代码行数:10,代码来源:notifications.py


示例5: __init__

	def __init__(self, *args, **kwargs): # we must support an empty init for PersistentObject
		self.f = None
		self._fileMetadata = None
		self._metadata = None
		self._useDb = True
		for key,value in kwargs.items():
			setattr(self, key, value)
		if len(args) == 1: # guess this is the url
			assert "url" not in kwargs
			self.url = args[0]
		if self.url:
			self.url = utils.convertToUnicode(self.url)
开发者ID:etel,项目名称:music-player,代码行数:12,代码来源:Song.py


示例6: ratingsIter

def ratingsIter():
	import urllib
	import re
	import utils
	for song in librarySongsIter:
		rating = song["Rating"]
		if rating is None: continue # print only songs with any rating set
		rating /= 100.0 # the maximum is 100
		fn = song["Location"]
		fn = urllib.unquote(fn)
		fn = re.sub("^file://(localhost)?", "", fn)
		fn = utils.convertToUnicode(fn)
		yield (fn, rating)
开发者ID:BMXE,项目名称:music-player,代码行数:13,代码来源:itunes.py


示例7: search

def search(query, limitResults=Search_ResultLimit):
	query = utils.convertToUnicode(query)
	cur = songSearchIndexDb._selectCmd("select docid from data where data match ? limit %i" % limitResults, (query,))
	results = [r[0] for r in cur]
	def getSongIdByRowId(rowId):
		songId = songSearchIndexRefDb._selectCmd("select songid from data where rowid=?", (rowId,)).fetchone()
		if songId is not None:
			songId = songId[0]
			return str(songId)
		return None
	results = map(getSongIdByRowId, results)
	results = map(getSongSummaryDictById, results)
	results = filter(None, results)
	return results
开发者ID:Lujaw,项目名称:music-player,代码行数:14,代码来源:songdb.py


示例8: insertSearchEntry_raw

def insertSearchEntry_raw(songId, tokens):
	songId = buffer(songId)
	with songSearchIndexRefDb.writelock:
		rowId = songSearchIndexRefDb._selectCmd("select rowid from data where songid=?", (songId,)).fetchone()
		if rowId is not None:
			rowId = rowId[0]
		else:
			# insert new
			songSearchIndexRefDb._actionCmd("insert into data(songid) values(?)", (songId,))
			rowId = songSearchIndexRefDb._selectCmd("select rowid from data where songid=?", (songId,)).fetchone()
			assert rowId is not None
			rowId = rowId[0]
	tokens = " ".join(tokens)
	tokens = utils.convertToUnicode(tokens)
	songSearchIndexDb._actionCmd("replace into data(docid, content) values (?,?)", (rowId, tokens))
开发者ID:Lujaw,项目名称:music-player,代码行数:15,代码来源:songdb.py


示例9: _export_m3u

def _export_m3u(path, songs):
	f = open(path, "wb")
	f.write("#EXTM3U\n\n")
	for song in songs:
		if isinstance(song, Song):
			song = {attrib: song.get(attrib, timeout=None)
					for attrib in ("id", "url", "artist", "title", "duration")}
		assert isinstance(song, dict)
		for attrib in ("url", "artist", "title"):
			song[attrib] = utils.convertToUnicode(song[attrib]).encode("utf8")
		f.write("#%s:id=%s\n" % (appinfo.appid, repr(song["id"])))
		f.write("#EXTINF:%i,%s - %s\n" % (song["duration"], song["artist"], song["title"]))
		f.write("%s\n\n" % song["url"])
	f.write("#Playlist finished with %i songs.\n\n" % len(songs))
	f.close()
开发者ID:albertz,项目名称:music-player,代码行数:15,代码来源:findbest.py


示例10: tableView_objectValueForTableColumn_row_

		def tableView_objectValueForTableColumn_row_(self, tableView, tableColumn, rowIndex):
			try:
				with self.lock:
					if rowIndex >= len(self.data):
						# This can happen if the data has changed in the middle
						# of a tableView.redraw().
						# Note that wrapping tableView.reloadData() doesn't work
						# because that doesn't reload it internally - it just delays
						# a redraw and inside the redraw, it reloads the data.
						# So, overriding redraw with locking might work.
						# But anyway, it doesn't really matter as we should have delayed
						# a further reloadData().
						# Also, in guiCocoa, there is another further workaround
						# which probably makes this obsolete.
						return None
					key = str(tableColumn.identifier())
					v = self.data[rowIndex].get(key, None)
					if key in self.formaters: v = self.formaters[key](v)
					if isinstance(v, str): v = utils.convertToUnicode(v)
					return v
			except Exception:
				import sys
				sys.excepthook(*sys.exc_info())
			return None
开发者ID:kingsj,项目名称:music-player,代码行数:24,代码来源:guiCocoaCommon.py


示例11: locateFile

def locateFile(filename):
	print "locateFile", utils.convertToUnicode(filename).encode("utf-8")
开发者ID:bryanjos,项目名称:music-player,代码行数:2,代码来源:gui.py


示例12: makeMetadataUnicode

	def makeMetadataUnicode(self, metadata=None):
		import utils
		if metadata is None: metadata = self.metadata
		for key, value in metadata.items():
			if not isinstance(value, str): continue
			metadata[key] = utils.convertToUnicode(value)
开发者ID:memres,项目名称:music-player,代码行数:6,代码来源:Song.py


示例13: handleRowIndex

 def handleRowIndex(index, stop):
     url = self.data[index].get("url", None)
     if url:
         url = utils.convertToUnicode(url)
         possibleSources.append(url)
开发者ID:antback,项目名称:music-player,代码行数:5,代码来源:guiCocoaCommon.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.copyfile函数代码示例发布时间:2022-05-26
下一篇:
Python utils.conv_bool函数代码示例发布时间: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