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


Python encodingUtils.smart_unicode函数代码示例

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


在下文中一共展示了smart_unicode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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