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


Python utils.encode函数代码示例

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


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

示例1: get_bold_colors

 def get_bold_colors(self, str):
     bolds = str.split(' ')
     for bold in bolds:
         try:
             self.colors[bold]['b'] = True
         except:
             print encode(_('The param "%s" does not exist for bold colors')) % bold
开发者ID:jstitch,项目名称:tyrs,代码行数:7,代码来源:config.py

示例2: listdir

 def listdir(self,directory):
     files = []
     dirs = []
 
     if(not directory.startswith('/')):
         directory = '/' + directory
     
     #get the id of this folder
     parentFolder = self._getGoogleFile(directory)
 
     #need to do this after
     if(not directory.endswith('/')):
             directory = directory + '/'
 
     if(parentFolder != None):
     
         fileList = self.drive.ListFile({'q':"'" + parentFolder['id'] + "' in parents and trashed = false"}).GetList()
    
         for aFile in fileList:
             if(aFile['mimeType'] == self.FOLDER_TYPE):
                 dirs.append(utils.encode(aFile['title']))
             else:
                 files.append(utils.encode(aFile['title']))
             
 
     return [dirs,files]    
开发者ID:elephunk84,项目名称:Kodi-Addons,代码行数:26,代码来源:vfs.py

示例3: generate_config_file

    def generate_config_file(self, config_file):
        conf = ConfigParser.RawConfigParser()
        conf.read(config_file)

        # COLOR
        conf.add_section('colors')
        for c in self.colors:
            conf.set('colors', c, self.colors[c]['c'])
        conf.set('colors', 'bold', '')
        # KEYS
        conf.add_section('keys')
        for k in self.keys:
            conf.set('keys', k, self.keys[k])
        # PARAMS
        conf.add_section('params')
        for p in self.params:
            if self.params[p] == True:
                value = 1
            elif self.params[p] == False:
                value = 0
            elif self.params[p] == None:
                continue
            else:
                value = self.params[p]

            conf.set('params', p, value)

        with open(config_file, 'wb') as config:
            conf.write(config)

        print encode(_('Genereting configuration file in %s')) % config_file
开发者ID:dmedvinsky,项目名称:tyrs,代码行数:31,代码来源:config.py

示例4: _raise_exception

	def _raise_exception():
		if raise_exception:
			if flags.rollback_on_exception:
				db.rollback()
			import inspect
			if inspect.isclass(raise_exception) and issubclass(raise_exception, Exception):
				raise raise_exception, encode(msg)
			else:
				raise ValidationError, encode(msg)
开发者ID:zeetyproyectos,项目名称:frappe,代码行数:9,代码来源:__init__.py

示例5: check_for_default_config

 def check_for_default_config(self):
     default_dir = '/tyrs'
     default_file = '/tyrs/tyrs.cfg'
     if not os.path.isfile(self.xdg_config + default_file):
         if not os.path.exists(self.xdg_config + default_dir):
             try:
                 os.makedirs(self.xdg_config + default_dir)
             except:
                 print encode(_('Couldn\'t create the directory in %s/tyrs')) % self.xdg_config
         self.generate_config_file(self.xdg_config + default_file)
开发者ID:dmedvinsky,项目名称:tyrs,代码行数:10,代码来源:config.py

示例6: test_incomplete_task

    def test_incomplete_task(self):
        """Send task messages without all required keys."""
        c = encode(source(constant))
        msg1 = {"module": c, "params": encode(())}
        msg2 = {"module": c, "dataset": []}
        msg3 = {"dataset": [], "params": encode(())}

        for msg in (msg1, msg2, msg3):
            self.write_command("task", msg)
            assert_true("missing key" in self.read_error_string())
开发者ID:jbenet,项目名称:qjam,代码行数:10,代码来源:test_worker.py

示例7: print_ask_service

def print_ask_service(token_file):
    print ''
    print encode(_('Couldn\'t find any profile.'))
    print ''
    print encode(_('It should reside in: %s')) % token_file
    print encode(_('If you want to setup a new account, then follow these steps'))
    print encode(_('If you want to skip this, just press return or ctrl-C.'))
    print ''

    print ''
    print encode(_('Which service do you want to use?'))
    print ''
    print '1. Twitter'
    print '2. Identi.ca'
    print ''
开发者ID:kezabelle,项目名称:tyrs,代码行数:15,代码来源:message.py

示例8: print_ask_service

def print_ask_service(config_file):
    print ''
    print encode(_('There is no profile detected.'))
    print ''
    print encode(_('It should be in %s')) % config_file
    print encode(_('If you want to setup a new account, let\'s go through some basic steps'))
    print encode(_('If you want to skip this, just press return or ctrl-C.'))
    print ''

    print ''
    print encode(_('Which service do you want to use?'))
    print ''
    print '1. Twitter'
    print '2. Identi.ca'
    print ''
开发者ID:jstitch,项目名称:tyrs,代码行数:15,代码来源:message.py

示例9: get_header

    def get_header(self, status):
        retweeted = ""
        reply = ""
        retweet_count = ""
        retweeter = ""
        source = self.get_source(status)
        nick = self.get_nick(status)
        time = self.get_time(status)

        if self.is_reply(status):
            reply = u" \u2709"
        if status.rt:
            retweeted = u" \u267b "
            retweeter = nick
            nick = self.origin_of_retweet(status)

        if self.get_retweet_count(status):
            retweet_count = str(self.get_retweet_count(status))

        header_template = self.conf.params["header_template"]
        header = unicode(header_template).format(
            time=time,
            nick=nick,
            reply=reply,
            retweeted=retweeted,
            source=source,
            retweet_count=retweet_count,
            retweeter=retweeter,
        )

        return encode(header)
开发者ID:dmedvinsky,项目名称:tyrs,代码行数:31,代码来源:interface.py

示例10: open_shell

 def open_shell(self):
     curses.endwin()
     if self.stdin_flag:
         os.system('sh')
     else:
         os.system('cd \"%s\"; sh' % encode(os.path.dirname(self.fc.filename)))
     curses.curs_set(0)
开发者ID:langner,项目名称:lfm,代码行数:7,代码来源:pyview.py

示例11: get_nick

    def get_nick(self, status):
        if hasattr(status, 'user'):
            nick = status.user.screen_name
        else:
            nick = status.sender_screen_name

        return encode(nick)
开发者ID:hobbestigrou,项目名称:tyrs,代码行数:7,代码来源:interface.py

示例12: send_refs

 def send_refs(self, refs, worker=None):
     if worker is None:
         worker = self._worker
     # Encode the objects in the refs.
     refs = [(x, encode(y)) for (x, y) in refs]
     msg = {"refs": refs}
     self.write_command("refs", msg, worker=worker)
开发者ID:jbenet,项目名称:qjam,代码行数:7,代码来源:test_worker.py

示例13: resolve

def resolve(query, dnsIP='192.55.83.30'):   # Default IP is local host
    _, Qs, _, _, _ = utils.dissectDNS(query)
    name = Qs[0][0]
    if name in cache:
        return cache[name]

    ID = struct.unpack('!H', query[0:2])[0]
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.sendto(query, (dnsIP, 53))

    whatReady = select.select([sock], [], [])
    if whatReady:  # Pythonic way of saying list is not empty
        rcvd = sock.recv(512*8)
        print utils.isAA(rcvd)
        sock.close()
        oneStep = doOneStep(rcvd)

        if oneStep is not None:
            if len(oneStep) == 2:
                if oneStep[1] == NOCHANGE:  # Continue our journey
                    return resolve(query, oneStep[0])
                elif oneStep[1] == ANSWER:
                    _, Qs, _, _, _ = utils.dissectDNS(query)
                    return oneStep[0]
            else:
                # CNAMEQUERY: make query with new address
                address = oneStep[2]
                query = utils.encode(address, False, ID)
                if oneStep[0] is not None:
                    return resolve(query, oneStep[0])
                else:
                    return resolve(query)
开发者ID:tomirio619,项目名称:DNS-Resolver,代码行数:32,代码来源:Resolver.py

示例14: put

 def put(self,source,dest):
     
     aFile = xbmcvfs.File(xbmc.translatePath(source),'r')
     
     self.zip.writestr(utils.encode(dest),aFile.read(),compress_type=zipfile.ZIP_DEFLATED)
     
     return True
开发者ID:mrlucas84,项目名称:xbmcbackup,代码行数:7,代码来源:vfs.py

示例15: display

    def display(self):
        """show status bar"""

        self.win.erase()
        adir = self.app.act_pane.act_tab
        maxw = self.app.maxw
        if len(adir.selections) > 0:
            if maxw >= 45:
                size = 0
                for f in adir.selections:
                    size += adir.files[f][files.FT_SIZE]
                self.win.addstr('    %s bytes in %d files' % \
                                (num2str(size), len(adir.selections)))
        else:
            if maxw >= 80:
                self.win.addstr('File: %4d of %-4d' % \
                                (adir.file_i + 1, adir.nfiles))
                filename = adir.sorted[adir.file_i]
                if adir.vfs:
                    realpath = os.path.join(vfs.join(self.app.act_pane.act_tab),
                                            filename)
                else:
                    realpath = files.get_realpath(adir.path, filename,
                                                  adir.files[filename][files.FT_TYPE])
                path = (len(realpath)>maxw-35) and \
                    '~' + realpath[-(maxw-37):] or realpath
                self.win.addstr(0, 20, 'Path: ' + utils.encode(path))
        if maxw > 10:
            try:
                self.win.addstr(0, maxw-8, 'F1=Help')
            except:
                pass
        self.win.refresh()
开发者ID:langner,项目名称:lfm,代码行数:33,代码来源:lfm.py


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