当前位置: 首页>>代码示例>>Python>>正文


Python Utf8.utf8ToLatin方法代码示例

本文整理汇总了Python中Utf8.utf8ToLatin方法的典型用法代码示例。如果您正苦于以下问题:Python Utf8.utf8ToLatin方法的具体用法?Python Utf8.utf8ToLatin怎么用?Python Utf8.utf8ToLatin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Utf8的用法示例。


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

示例1: addCache

# 需要导入模块: import Utf8 [as 别名]
# 或者: from Utf8 import utf8ToLatin [as 别名]
def addCache(url, text):
	
	# this line should be moved to a more suitable place
	createCacheFolder()
	
	try:
		if folderSize(cacheDir) > 4.0 or freeSpace(cacheDir) < 2.0: #10mb
			for f in os.listdir(cacheDir):
				file = os.path.join(cacheDir, f)
				printl("RM: " + str(file), __name__)
				os.remove(file)
		
		cacheFile = re.sub(r'\W', "", url).strip()
		cacheFileName = cacheDir + u"/" + cacheFile + u".cache"
		if text is not None and len(text) > 0:
			f = Utf8.Utf8(cacheFileName, "w")
			f.write(text)
			f.close
			
			if os.path.getsize(Utf8.utf8ToLatin(cacheFileName)) == 0:
				os.remove(Utf8.utf8ToLatin(cacheFileName))
			
	except Exception, ex:
		printl("Exception (ef): " + str(ex), __name__, "E")
		printl("\tURL: " + str(Utf8.utf8ToLatin(url)), __name__, "E")
开发者ID:TELE-TWIN,项目名称:ProjectValerie,代码行数:27,代码来源:WebGrabber.py

示例2: isNfoAvailable

# 需要导入模块: import Utf8 [as 别名]
# 或者: from Utf8 import utf8ToLatin [as 别名]
	def isNfoAvailable(self, name):
		try:
			printl("Check presence of nfo file: " + Utf8.utf8ToLatin(name + u".nfo"), self, "I")
			if os.path.isfile(Utf8.utf8ToLatin(name + u".nfo")):
				return True
		except Exception, ex:
			printl("Exception (ef): " + str(ex), self, "E")
开发者ID:OpenMipsel,项目名称:project-valerie,代码行数:9,代码来源:MediaInfo.py

示例3: isEnigma2Recording

# 需要导入模块: import Utf8 [as 别名]
# 或者: from Utf8 import utf8ToLatin [as 别名]
	def isEnigma2Recording(self, name):
		try:
			if os.path.isfile(Utf8.utf8ToLatin(name + u".meta")):
				printl("Found E2 meta file: " + str(Utf8.utf8ToLatin(name + u".meta")), self)
				return True
		except Exception, ex:
			printl("Exception (ef): " + str(ex), self, "E")
开发者ID:OpenMipsel,项目名称:project-valerie,代码行数:9,代码来源:MediaInfo.py

示例4: removeFromCache

# 需要导入模块: import Utf8 [as 别名]
# 或者: from Utf8 import utf8ToLatin [as 别名]
def removeFromCache(url):
	try:
		cacheFile = re.sub(r'\W', "", url).strip()
		cacheFileName = cacheDir + u"/" + cacheFile + u".cache"
		
		if os.path.isfile(Utf8.utf8ToLatin(cacheFileName)):
			os.remove(Utf8.utf8ToLatin(cacheFileName))
	except Exception, ex:
		printl("Exception (ef): " + str(ex), __name__, "E")
		printl("\tURL: " + str(Utf8.utf8ToLatin(url)), __name__, "E")
开发者ID:TELE-TWIN,项目名称:ProjectValerie,代码行数:12,代码来源:WebGrabber.py

示例5: setValerieInfoLastAccessTime

# 需要导入模块: import Utf8 [as 别名]
# 或者: from Utf8 import utf8ToLatin [as 别名]
	def setValerieInfoLastAccessTime(self, path):
		try:
			if os.path.isfile(Utf8.utf8ToLatin(path + u"/valerie.info")):
				time = int(os.path.getctime(Utf8.utf8ToLatin(path + u"/valerie.info")))
				f = Utf8.Utf8(path + u"/.access", "w")
				time = f.write(str(time) + u"\n")
				f.close()
			elif os.path.isfile(Utf8.utf8ToLatin(path + u"/.access")):
				os.remove(Utf8.utf8ToLatin(path + u"/.access"))
		except Exception, ex:
			printl("Exception (ef): " + str(ex), self, "E")
开发者ID:OpenMipsel,项目名称:project-valerie,代码行数:13,代码来源:MediaInfo.py

示例6: getValerieInfoAccessTime

# 需要导入模块: import Utf8 [as 别名]
# 或者: from Utf8 import utf8ToLatin [as 别名]
	def getValerieInfoAccessTime(self, path):
		time = 0
		try:
			if os.path.isfile(Utf8.utf8ToLatin(path + u"/valerie.info")):
				try:
					time = int(os.path.getctime(Utf8.utf8ToLatin(path + u"/valerie.info")))
				except Exception, ex:
							printl("Exception: " + str(ex), self)
							printl("\t" + str(Utf8.utf8ToLatin(path + u"/valerie.info")), self)
		
		except Exception, ex:
			printl("Exception (ef): " + str(ex), self, "E")
开发者ID:OpenMipsel,项目名称:project-valerie,代码行数:14,代码来源:MediaInfo.py

示例7: checkCache

# 需要导入模块: import Utf8 [as 别名]
# 或者: from Utf8 import utf8ToLatin [as 别名]
def checkCache(url):
	try:
		cacheFile = re.sub(r'\W', "", url).strip()
		cacheFileName = cacheDir + u"/" + cacheFile + u".cache"
		rtv = None
		if os.path.isfile(Utf8.utf8ToLatin(cacheFileName)):
			if os.path.getsize(Utf8.utf8ToLatin(cacheFileName)) == 0:
				os.remove(Utf8.utf8ToLatin(cacheFileName))
				return rtv
			f = Utf8.Utf8(cacheDir + u"/" + cacheFile + u".cache", "r")
			rtv = f.read()
			f.close()
	except Exception, ex:
		printl("Exception (ef): " + str(ex), __name__, "E")
		printl("\tURL: " + str(Utf8.utf8ToLatin(url)), __name__, "E")
开发者ID:TELE-TWIN,项目名称:ProjectValerie,代码行数:17,代码来源:WebGrabber.py

示例8: getPlot

# 需要导入模块: import Utf8 [as 别名]
# 或者: from Utf8 import utf8ToLatin [as 别名]
	def getPlot(self, info, html):
		printl("->", self)
		plot = self.getDetails(html)
		if plot is None:
			printl("<- (if plot is None: a)", self, "W")
			return None
		#print "plot", plot
		pos = plot.find(self.DIV_PLOT_START)
		if pos < 0:
			printl("Details " + plot, self, "W")
			printl("<- (if pos < 0: b)", self, "W")
			return None
		
		plot = plot[pos + len(self.DIV_PLOT_START):]
		
		pos = plot.find(self.DIV_PLOT_END)
		if pos < 0:
			printl("<- (if pos < 0: c)", self, "W")
			return None
		plot = plot[0:pos]
		plot = plot.strip()
		info.Plot = plot
		info.Plot += u" [M.IMDB.COM]" 
		printl("<- Plot: " + Utf8.utf8ToLatin(plot), self)
		return info
开发者ID:TELE-TWIN,项目名称:ProjectValerie,代码行数:27,代码来源:MobileImdbComProvider.py

示例9: getXml

# 需要导入模块: import Utf8 [as 别名]
# 或者: from Utf8 import utf8ToLatin [as 别名]
def getXml(url, rawXml=None, cache=True):
	if rawXml is None:
		rawXml = getText(url, cache=cache)
	
	if rawXml is None:
		return None
	
	decodedXml = None
	try:
		decodedXml = minidom.parseString(rawXml.encode( "utf-8", 'ignore' ))
		printl("encoded utf-8")
		return decodedXml
	except Exception, ex:
		printl("minidom.parseString as utf-8 failed, retrieing as latin-1. Ex: " + str(ex), __name__, "W")
		try:
			decodedXml = minidom.parseString(rawXml.encode( "latin-1", 'ignore' ))
			printl("encoded latin-1")
			return decodedXml
		except Exception, ex:
			printl("minidom.parseString as utf-8 failed, retrieing as windows-1252. Ex: " + str(ex), __name__, "W")
			try:
				decodedXml = minidom.parseString(rawXml.encode( "windows-1252", 'ignore' ))
				printl("encoded iso8859-1")
				return decodedXml
			except Exception, ex:
				printl("minidom.parseString as utf-8 failed, retrieing as utf-8. Ex: " + str(ex), __name__, "W")
				try:
					decodedXml = minidom.parseString(rawXml.decode("cp1252").encode("utf-8"))
					printl("encoded cp1252")
					return decodedXml
				except Exception, ex:
					printl("minidom.parseString as utf-8 and latin-1 failed, ignoring. Ex: " + str(ex), __name__, "E")
					printl("URL: " + str(Utf8.utf8ToLatin(url)), __name__, "E")
					printl("<" + str(type(ex)) + "> Ex: " + str(ex), __name__, "E")
开发者ID:TELE-TWIN,项目名称:ProjectValerie,代码行数:36,代码来源:WebGrabber.py

示例10: getGenre

# 需要导入模块: import Utf8 [as 别名]
# 或者: from Utf8 import utf8ToLatin [as 别名]
	def getGenre(self, info, html):
		printl("->", self)
		genre = self.getDetails(html)
		if genre is None:
			printl("<- (if genre is None: a)", self, "W")
			return None
		#print "genre", genre
		pos = genre.find(self.DIV_GENRE_START)
		if pos < 0:
			printl("Details " + genre, self, "W")
			printl("<- (if pos < 0: b)", self, "W")
			return None
		
		genre = genre[pos + len(self.DIV_GENRE_START):]
		
		pos = genre.find(self.DIV_GENRE_END)
		if pos < 0:
			printl("<- (if pos < 0: c)", self, "W")
			return None
		genre = genre[0:pos]
		genre = genre.strip()
		
		if len(genre) < 3:
			printl("<- (en(genre) < 3)", self, "W")
			return None
		
		info.Genres = u""
		
		genres = genre.split(", ")
		for genre in genres:
			info.Genres += genre + u"|"
		if len(info.Genres) > 1:
			info.Genres = info.Genres[:len(info.Genres) - 1]
		printl("<- Genres: " + Utf8.utf8ToLatin(info.Genres), self)
		return info
开发者ID:TELE-TWIN,项目名称:ProjectValerie,代码行数:37,代码来源:MobileImdbComProvider.py

示例11: _verifyAndDeleteMissingFiles

# 需要导入模块: import Utf8 [as 别名]
# 或者: from Utf8 import utf8ToLatin [as 别名]
	def _verifyAndDeleteMissingFiles(self, records):
		for m in records:
			# don't verify series, will remaian with episodes count =0 is needed
			if m.isTypeSerie():
				continue
			path = m.Path + u"/" + m.Filename + u"." + m.Extension
			#printl("path: " + path, self)
			if os.path.exists(Utf8.utf8ToLatin(path)) is False:
				self.dbHandler.markAsMissing(m.Id) 
开发者ID:OpenMipsel,项目名称:project-valerie,代码行数:11,代码来源:PVS_DatabaseHandler.py

示例12: getValerieInfoLastAccessTime

# 需要导入模块: import Utf8 [as 别名]
# 或者: from Utf8 import utf8ToLatin [as 别名]
	def getValerieInfoLastAccessTime(self, path):
		time = 0
		try:
			if os.path.isfile(Utf8.utf8ToLatin(path + u"/.access")):
				f = Utf8.Utf8(path + u"/.access", "r")
				lines = f.read()
				if lines is not None:
					lines = lines.split(u"\n")
					if len(lines) >= 1:
						try:
							lines = lines[0].split(".")
							time = int(lines[0])
						except Exception, ex:
							printl("Exception: " + str(ex), self)
							printl("\t" + str(Utf8.utf8ToLatin(path + u"/.access")), self)
				f.close()
		except Exception, ex:
			printl("Exception (ef): " + str(ex), self, "E")
开发者ID:OpenMipsel,项目名称:project-valerie,代码行数:20,代码来源:MediaInfo.py

示例13: getHtml

# 需要导入模块: import Utf8 [as 别名]
# 或者: from Utf8 import utf8ToLatin [as 别名]
def getHtml(url, cache=True):
	try:
		rawHtml = getText(url, cache=cache) 
		decodedHtml = None
		if rawHtml is not None:
			decodedHtml = decode_htmlentities(rawHtml)
	except Exception, ex:
		printl("Exception (ef): " + str(ex), __name__, "E")
		printl("\tURL: " + str(Utf8.utf8ToLatin(url)), __name__, "E")
开发者ID:TELE-TWIN,项目名称:ProjectValerie,代码行数:11,代码来源:WebGrabber.py

示例14: getCRC32OfMedia

# 需要导入模块: import Utf8 [as 别名]
# 或者: from Utf8 import utf8ToLatin [as 别名]
	def getCRC32OfMedia(self, media):
		media.CRCOffset = 0
		if media.Extension.lower() == u"ifo":
			filename = Utf8.utf8ToLatin(media.Path + u"/VIDEO_TS.VOB")
		else:
			filename = Utf8.utf8ToLatin(media.Path + u"/" + media.Filename + u"." + media.Extension)
			if media.FileSize <= 1000:
				media.CRCSize = media.FileSize
			else:
				media.CRCOffset = 200
				
		media.CRCFile = filename #filename
		
		f = file(filename, 'rb')
		f.seek(media.CRCOffset)
		x = f.read(media.CRCSize)
		f.close()
		x = binascii.crc32(x) #binascii.a2b_hex('18329a7e')
		return format(x & 0xFFFFFFFF, '08x') 
开发者ID:OpenMipsel,项目名称:project-valerie,代码行数:21,代码来源:PVS_DatabaseHandlerPICKLEV2.py

示例15: __str__

# 需要导入模块: import Utf8 [as 别名]
# 或者: from Utf8 import utf8ToLatin [as 别名]
	def __str__(self):
		printl("->", self, "S")	
		try:
			rtv = unicode(self.getMediaCount(MediaInfo.MOVIE)) + \
					u" " + \
					unicode(self.getMediaCount(MediaInfo.SERIE)) + \
					u" " + \
					unicode(self.getMediaCount(MediaInfo.EPISODE))
			return Utf8.utf8ToLatin(rtv)
		except Exception, ex:
			printl("Error retriving _str_: "+ str(ex), self, "W")
			return "Error retriving _str_"			
开发者ID:OpenMipsel,项目名称:project-valerie,代码行数:14,代码来源:PVS_DatabaseHandler.py


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