本文整理汇总了Python中utils.encodingUtils.smart_unicode函数的典型用法代码示例。如果您正苦于以下问题:Python smart_unicode函数的具体用法?Python smart_unicode怎么用?Python smart_unicode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了smart_unicode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: changeFanart
def changeFanart(self, cfgFile, item, newFanart):
if os.path.exists(cfgFile):
fav = self._createFavourite(item)
newfav = self._createFavourite(item, fanart=newFanart)
old = fu.getFileContent(cfgFile)
new = old.replace(enc.smart_unicode(fav).encode('utf-8'), enc.smart_unicode(newfav).encode('utf-8'))
fu.setFileContent(cfgFile, new)
开发者ID:rollysalvana,项目名称:pampereo-xbmc-plugins,代码行数:7,代码来源:favouritesManager.py
示例2: replaceFromDict
def replaceFromDict(dictFilePath, wrd):
dictionary = enc.smart_unicode(getFileContent(dictFilePath))
dictionary = dictionary.replace('\r\n','\n')
p_reg = re.compile('^[^\r\n]+$', re.IGNORECASE + re.DOTALL + re.MULTILINE)
m_reg = p_reg.findall(dictionary)
word = enc.smart_unicode(wrd).replace(u'Ãœ','Ü').replace(u'Ö','Ö').replace(u'Ä','Ä')
try:
if m_reg and len(m_reg) > 0:
index = ''
words = []
newword = ''
for m in m_reg:
if not m.startswith(' '):
index = m
del words[:]
else:
replWord = m.strip()
words.append(replWord)
if word.find(' ') != -1:
newword = word.replace(replWord,index)
if (word in words) or (word == index):
return index
if newword != '' and newword != word:
return newword
except:
common.log('Skipped Replacement: ' + word)
return word
开发者ID:Gemini88,项目名称:addons,代码行数:33,代码来源:customConversions.py
示例3: replace
def replace(params, src):
src = enc.smart_unicode(src)
paramArr = __parseParams(enc.smart_unicode(params))
paramstr = paramArr[0].replace('%s', src)
paramSrch = paramArr[1]
paramRepl = paramArr[2]
return paramstr.replace(paramSrch,paramRepl)
开发者ID:Gemini88,项目名称:addons,代码行数:7,代码来源:customConversions.py
示例4: changeLabel
def changeLabel(self, item, newLabel):
found = self._findItem(item)
if found:
item['title'] = newLabel
[cfgFile, data, fav] = found
# if it's a virtual folder, rename file, rename header, update link
if self._isVirtualFolder(item):
url = item.getInfo('url')
oldFile = self._getFullPath(url)
newFilename = urllib.quote_plus(fu.cleanFilename(newLabel))
virtualFolderFile = newFilename + '.cfg'
physicalFolder = os.path.normpath(self._favouritesFoldersFolder)
virtualFolderPath = os.path.join(physicalFolder, virtualFolderFile)
# check if new target is valid
if os.path.exists(virtualFolderPath):
prefix = newFilename + '-'
suffix = '.cfg'
virtualFolderFile = fu.randomFilename(directory=physicalFolder, prefix=prefix, suffix=suffix)
virtualFolderPath = os.path.join(physicalFolder, virtualFolderFile)
# update header
content = fu.getFileContent(oldFile)
oldHeader = self.cfgBuilder.buildHeader(item['title'])
newHeader = self.cfgBuilder.buildHeader(newLabel)
content = content.replace(oldHeader, newHeader)
# rename file
self._removeVirtualFolder(oldFile, False)
fu.setFileContent(virtualFolderPath, content)
# update link
item['url'] = self._getShortPath(virtualFolderPath)
newfav = self._createFavourite(item)
new = data.replace(fav, enc.smart_unicode(newfav).encode('utf-8'))
fu.setFileContent(cfgFile, new)
开发者ID:Anniyan,项目名称:SportsDevil-Fixes,代码行数:32,代码来源:favouritesManager.py
示例5: changeFanart
def changeFanart(self, item, newFanart):
found = self._findItem(item)
if found:
[cfgFile, data, fav] = found
newfav = self._createFavourite(item, fanart=newFanart)
new = data.replace(fav, enc.smart_unicode(newfav).encode('utf-8'))
fu.setFileContent(cfgFile, new)
开发者ID:Anniyan,项目名称:SportsDevil-Fixes,代码行数:7,代码来源:favouritesManager.py
示例6: moveToFolder
def moveToFolder(self, cfgFile, item, newCfgFile):
if os.path.exists(cfgFile) and os.path.exists(newCfgFile):
fav = self._createFavourite(item)
old = fu.getFileContent(cfgFile)
new = old.replace(enc.smart_unicode(fav).encode('utf-8'),'')
fu.setFileContent(cfgFile, new)
fu.appendFileContent(newCfgFile, fav)
开发者ID:rollysalvana,项目名称:pampereo-xbmc-plugins,代码行数:7,代码来源:favouritesManager.py
示例7: changeIcon
def changeIcon(self, item, newIcon):
found = self._findItem(item)
if found:
[cfgFile, data, fav] = found
newfav = self._createFavourite(item, icon=newIcon)
new = data.replace(fav, enc.smart_unicode(newfav).encode("utf-8"))
fu.setFileContent(cfgFile, new)
开发者ID:aamkTV,项目名称:githamtv.github.io,代码行数:7,代码来源:favouritesManager.py
示例8: getInfo
def getInfo(item, params, src):
src = enc.smart_unicode(src).encode('utf-8')
paramArr = __parseParams(params)
paramPage = paramArr[0].replace('%s', src)
if paramPage.startswith('@') and paramPage.endswith('@'):
paramPage = item.getInfo(paramPage.strip('@'))
paramRegex = paramArr[1].replace('%s', src)
if paramRegex.startswith('@') and paramRegex.endswith('@'):
paramRegex = item.getInfo(paramRegex.strip('@'))
referer = ''
form_data = ''
variables=[]
if len(paramArr) > 2:
referer = paramArr[2]
referer = referer.replace('%s', src)
if referer.startswith('@') and referer.endswith('@'):
referer = item.getInfo(referer.strip('@'))
if len(paramArr) > 3:
variables = paramArr[3].strip("'").split('|')
common.log('Get Info from: "'+ paramPage + '" from "' + referer + '"')
try:
parts = (paramPage.split('|', 1) + [None] * 2)[:2]
paramPage, form_data = parts
form_data = urlparse.parse_qsl(form_data)
except:
pass
data = common.getHTML(paramPage, form_data, referer, referer!='',demystify=True)
return reg.parseText(data, paramRegex, variables)
开发者ID:crawlers1977,项目名称:plugin.video.SportsDevil,代码行数:34,代码来源:customConversions.py
示例9: getInfo
def getInfo(item, params, src):
src = enc.smart_unicode(src).encode('utf-8')
paramArr = __parseParams(params)
paramPage = paramArr[0].replace('%s', src)
paramPage = urllib.unquote(paramPage)
if paramPage.startswith('@') and paramPage.endswith('@'):
paramPage = item.getInfo(paramPage.strip('@'))
paramRegex = paramArr[1].replace('%s', src)
if paramRegex.startswith('@') and paramRegex.endswith('@'):
paramRegex = item.getInfo(paramRegex.strip('@'))
referer = ''
variables=[]
if len(paramArr) > 2:
referer = paramArr[2]
referer = referer.replace('%s', src)
if referer.startswith('@') and referer.endswith('@'):
referer = item.getInfo(referer.strip('@'))
if len(paramArr) > 3:
variables = paramArr[3].strip("'").split('|')
common.log('Get Info from: "'+ paramPage + '" from "' + referer + '"')
data = common.getHTML(paramPage, referer, referer!='')
return reg.parseText(data, paramRegex, variables)
开发者ID:Gemini88,项目名称:addons,代码行数:26,代码来源:customConversions.py
示例10: codeUrl
def codeUrl(item):
params = ''
for info_name in item.infos_names:
if info_name != 'url' and info_name.find('.tmp') == -1:
info_value = item[info_name]
try:
value = urllib.quote(enc.smart_unicode(info_value).encode('utf-8'))
except:
value = enc.smart_unicode(info_value)
keyValPair = enc.smart_unicode(info_name) + ':' + value
params += '&' + keyValPair
try:
url = enc.smart_unicode(urllib.quote_plus(item['url']))
except:
url = item['url']
params += '&url:' + url
return params.lstrip('&')
开发者ID:rollysalvana,项目名称:pampereo-xbmc-plugins,代码行数:19,代码来源:main.py
示例11: parseText
def parseText(params, src):
src = enc.smart_unicode(src)
paramArr = __parseParams(params)
text = paramArr[0].replace('%s',src)
regex = paramArr[1].replace('%s', src)
variables = []
if len(paramArr) > 2:
variables = paramArr[2].split('|')
return reg.parseText(text, regex, variables)
开发者ID:rollysalvana,项目名称:pampereo-xbmc-plugins,代码行数:10,代码来源:customConversions.py
示例12: buildItem
def buildItem(self, title, m_type, url, icon=None, fanart=None, cfg=None):
sepLine = self.buildSeperator(title)
data = ["\n" + sepLine, "title=" + enc.smart_unicode(title), "type=" + m_type]
if icon:
data.append("icon=" + icon)
if fanart:
data.append("fanart=" + fanart)
if cfg:
data.append("cfg=" + cfg)
data.append("url=" + url)
return "\n".join(data)
开发者ID:aamkTV,项目名称:githamtv.github.io,代码行数:11,代码来源:favouritesManager.py
示例13: replaceRegex
def replaceRegex(params, src):
src = enc.smart_unicode(src)
paramArr = __parseParams(params)
paramStr = paramArr[0].replace('%s', src)
paramSrch = paramArr[1]
paramRepl = paramArr[2]
r = re.compile(paramSrch, re.DOTALL + re.IGNORECASE)
ms = r.findall(paramStr)
if ms:
for m in ms:
paramStr = paramStr.replace(m, paramRepl,1)
return paramStr
return src
开发者ID:Gemini88,项目名称:addons,代码行数:14,代码来源:customConversions.py
示例14: buildItem
def buildItem(self, title, m_type, url, icon=None, fanart=None, cfg=None):
sepLine = self.buildSeperator(title)
data = [
'\n' + sepLine,
'title=' + enc.smart_unicode(title),
'type=' + m_type
]
if icon:
data.append('icon=' + icon)
if fanart:
data.append('fanart=' + fanart)
if cfg:
data.append('cfg=' + cfg)
data.append('url=' + url)
return '\n'.join(data)
开发者ID:Anniyan,项目名称:SportsDevil-Fixes,代码行数:15,代码来源:favouritesManager.py
示例15: changeLabel
def changeLabel(self, cfgFile, item, newLabel):
if os.path.exists(cfgFile):
oldfav = self._createFavourite(item)
old = fu.getFileContent(cfgFile)
# if it's a virtual folder, change target url too; check if target already exists; rename target
# (helpful, if you want to edit files manually)
if self._isVirtualFolder(item):
url = item.getInfo('url')
oldTargetFile = os.path.join(self._favouritesFoldersFolder, url.split('/')[1])
# check if new target is valid
newTargetFile = os.path.join(self._favouritesFoldersFolder, urllib.quote_plus(newLabel) + '.cfg')
if os.path.exists(newTargetFile):
common.showInfo('Folder already exists')
return
# rename target
os.rename(oldTargetFile, newTargetFile)
# update target url
item.setInfo('url', 'favfolders/' + urllib.quote_plus(newLabel) + '.cfg')
newfav = self._createFavourite(item, title=newLabel)
new = old.replace(enc.smart_unicode(oldfav).encode('utf-8'), enc.smart_unicode(newfav).encode('utf-8'))
fu.setFileContent(cfgFile, new)
开发者ID:rollysalvana,项目名称:pampereo-xbmc-plugins,代码行数:24,代码来源:favouritesManager.py
示例16: removeItem
def removeItem(self, item):
cfgFile = self._favouritesFile
definedIn = item.getInfo('definedIn')
if definedIn and definedIn.startswith('favfolders/'):
cfgFile = os.path.join(self._favouritesFoldersFolder, definedIn.split('/')[1])
if os.path.exists(cfgFile):
fav = self._createFavourite(item)
old = fu.getFileContent(cfgFile)
new = old.replace(enc.smart_unicode(fav).encode('utf-8'),'')
fu.setFileContent(cfgFile, new)
# delete virtual folder
if self._isVirtualFolder(item):
self._removeVirtualFolder(item)
开发者ID:rollysalvana,项目名称:pampereo-xbmc-plugins,代码行数:15,代码来源:favouritesManager.py
示例17: parseText
def parseText(item, params, src):
src = enc.smart_unicode(src)
paramArr = __parseParams(params)
text = paramArr[0].replace('%s',src)
if text.startswith('@') and text.endswith('@'):
text = item.getInfo(text.strip('@'))
regex = paramArr[1].replace('%s', src)
if regex.startswith('@') and regex.endswith('@'):
regex = item.getInfo(regex.strip('@'))
variables = []
if len(paramArr) > 2:
variables = paramArr[2].split('|')
return reg.parseText(text, regex, variables)
开发者ID:Gemini88,项目名称:addons,代码行数:16,代码来源:customConversions.py
示例18: getInfo
def getInfo(item, params, src, xml=False):
src = enc.smart_unicode(src).encode('utf-8')
paramArr = __parseParams(params)
paramPage = paramArr[0].replace('%s', src)
if paramPage.startswith('@') and paramPage.endswith('@'):
paramPage = item.getInfo(paramPage.strip('@'))
paramRegex = paramArr[1].replace('%s', src)
if paramRegex.startswith('@') and paramRegex.endswith('@'):
paramRegex = item.getInfo(paramRegex.strip('@'))
referer = ''
form_data = ''
variables=[]
if len(paramArr) > 2:
referer = paramArr[2]
referer = referer.replace('%s', src)
if referer.startswith('@') and referer.endswith('@'):
referer = item.getInfo(referer.strip('@'))
if len(paramArr) > 3:
variables = paramArr[3].strip("'").split('|')
parsed_link = urlparse.urlsplit(referer)
parsed_link = parsed_link._replace(netloc=parsed_link.netloc.encode('idna'),path=urllib.quote(parsed_link.path.encode('utf-8')))
referer = parsed_link.geturl().encode('utf-8')
try:
parts = (paramPage.split('|', 1) + [None] * 2)[:2]
paramPage, form_data = parts
form_data = urlparse.parse_qsl(form_data)
except:
pass
common.log('Get Info from: "'+ paramPage + '" from "' + referer + '"')
data = common.getHTML(paramPage, form_data, referer, xml, ignoreCache=False,demystify=True)
return reg.parseText(data, paramRegex, variables)
开发者ID:agh039,项目名称:husham.com,代码行数:38,代码来源:customConversions.py
示例19: __parseHtml
def __parseHtml(self, url, data, rules, skills, definedIn, lItem):
#common.log('_parseHtml called')
items = []
for item_rule in rules:
# common.log('rule: ' + item_rule.infos)
if not hasattr(item_rule, 'precheck') or (item_rule.precheck in data):
revid = re.compile(item_rule.infos, re.IGNORECASE + re.DOTALL + re.MULTILINE)
for reinfos in revid.findall(data):
tmp = CListItem()
if lItem['referer']:
tmp['referer'] = lItem['referer']
if item_rule.order.find('|') != -1:
infos_names = item_rule.order.split('|')
infos_values = list(reinfos)
i = 0
for name in infos_names:
tmp[name] = infos_values[i]
i = i+1
else:
tmp[item_rule.order] = reinfos
for info in item_rule.info_list:
info_value = tmp[info.name]
if info_value:
if info.build.find('%s') != -1:
tmpVal = enc.smart_unicode(info.build % enc.smart_unicode(info_value))
tmp[info.name] = tmpVal
continue
if info.build.find('%s') != -1:
if info.src.__contains__('+'):
tmpArr = info.src.split('+')
src = ''
for t in tmpArr:
t = t.strip()
if t.find('\'') != -1:
src = src + t.strip('\'')
else:
src = src + enc.smart_unicode(tmp[t])
elif info.src.__contains__('||'):
variables = info.src.split('||')
src = firstNonEmpty(tmp, variables)
else:
src = tmp[info.src]
if src and info.convert != []:
src = self.__parseCommands(tmp, src, info.convert)
if isinstance(src, dict):
for dKey in src:
tmp[dKey] = src[dKey]
src = src.values()[0]
info_value = info.build % (enc.smart_unicode(src))
else:
info_value = info.build
tmp[info.name] = info_value
tmp['url'] = enc.smart_unicode(item_rule.url_build % (enc.smart_unicode(tmp['url'])))
tmp.merge(lItem)
if item_rule.skill.find('append') != -1:
tmp['url'] = url + tmp['url']
if item_rule.skill.find('space') != -1:
tmp['title'] = ' %s ' % tmp['title'].strip()
if skills.find('videoTitle') > -1:
tmp['videoTitle'] = tmp['title']
tmp['definedIn'] = definedIn
items.append(tmp)
return items
开发者ID:aamkTV,项目名称:githamtv.github.io,代码行数:80,代码来源:parser.py
示例20: __parseCommands
def __parseCommands(self, item, src, convCommands):
# common.log('_parseCommands called')
# helping function
def parseCommand(txt):
command = {"command": txt, "params": ""}
if txt.find("(") > -1:
command["command"] = txt[0 : txt.find("(")]
command["params"] = txt[len(command["command"]) + 1 : -1]
return command
try:
src = src.encode("utf-8")
except:
pass
for convCommand in convCommands:
pComm = parseCommand(convCommand)
command = pComm["command"]
params = pComm["params"]
if params.find("@[email protected]"):
referer = item["referer"]
if not referer:
referer = ""
params = params.replace("@[email protected]", referer)
if command == "convDate":
src = cc.convDate(params, src)
elif command == "convTimestamp":
src = cc.convTimestamp(params, src)
elif command == "select":
src = cc.select(params, src)
if not src:
continue
elif command == "smart_unicode":
src = enc.smart_unicode(params.strip("'").replace("%s", src))
elif command == "safeGerman":
src = enc.safeGerman(src)
elif command == "safeRegex":
src = enc.safeRegexEncoding(params.strip("'").replace("%s", enc.smart_unicode(src)))
elif command == "replaceFromDict":
dictName = str(params.strip("'"))
path = os.path.join(common.Paths.dictsDir, dictName + ".txt")
if not (os.path.exists(path)):
common.log("Dictionary file not found: " + path)
continue
src = cc.replaceFromDict(path, src)
elif command == "time":
src = time.time()
elif command == "timediff":
src = dt.timediff(src, params.strip("'"))
elif command == "offset":
src = cc.offset(params, src)
elif command == "getSource":
src = cc.getSource(params, src)
elif command == "getRedirect":
src = get_redirected_url(params.strip("'").replace("%s", src))
elif command == "quote":
try:
src = urllib.quote(params.strip("'").replace("%s", urllib.quote(src)))
except:
cleanParams = params.strip("'")
cleanParams = cleanParams.replace("%s", src.encode("utf-8"))
src = urllib.quote(cleanParams)
elif command == "unquote":
src = urllib.unquote(params.strip("'").replace("%s", src))
elif command == "parseText":
src = cc.parseText(item, params, src)
elif command == "getInfo":
src = cc.getInfo(item, params, src)
elif command == "decodeBase64":
src = cc.decodeBase64(src)
elif command == "decodeRawUnicode":
src = cc.decodeRawUnicode(src)
elif command == "replace":
src = cc.replace(params, src)
elif command == "replaceRegex":
src = cc.replaceRegex(params, src)
elif command == "ifEmpty":
src = cc.ifEmpty(item, params, src)
#.........这里部分代码省略.........
开发者ID:cyberwarrior,项目名称:dmind,代码行数:101,代码来源:parser.py
注:本文中的utils.encodingUtils.smart_unicode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论