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


Python string.lstrip函数代码示例

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


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

示例1: emgr_params

 def emgr_params(self):
     """
     Reads EMGR_SNAP and returns LIST with info about installed ifixes
     """
     EMGR = []
     if self.EMGR_SNAP:
         conffile = self.EMGR_SNAP
         while True:
             line = conffile.readline()
             if 'LABEL:' in line:
                 emgr_label = lstrip(line.split(':')[1].rstrip('\r\n'))
                 conffile.readline()
                 conffile.readline()
                 line = conffile.readline()
                 emgr_status = lstrip(line.split(':')[1].rstrip('\r\n'))
                 conffile.readline()
                 line = conffile.readline()
                 emgr_abstruct = lstrip(line.split(':')[1].rstrip('\r\n'))
                 conffile.readline()
                 conffile.readline()
                 line = conffile.readline()
                 emgr_instdate = lstrip(line.split(':')[1].split()[0].rstrip('\r\n'))
                 EMGR.append({'emgr_label': emgr_label, 'emgr_status': emgr_status,
                              'emgr_abstruct': emgr_abstruct, 'emgr_instdate': emgr_instdate})
             if not line:
                 break
     else :
         return None
     return EMGR
开发者ID:vpluzhnikov,项目名称:confcenter,代码行数:29,代码来源:aixsnap.py

示例2: LookForNext

def LookForNext(newlines, i):
    currLevel = GetLevel(newlines[i])
    if currLevel==1:
        return string.lstrip(newlines[i], '-')

    #if it's the last element in input list
    if i==len(newlines)-1:
        parent = LookForParent(newlines,i)
        firstChild = newlines.index('-'*(currLevel-1)+parent)+1
        return string.lstrip(newlines[firstChild], '-')

    #from the next in input list to the end
    for j in range(i+1, len(newlines)):
        level = GetLevel(newlines[j])
        #if further is "upper"
        if level < currLevel:
            #looke for parent
            parent = LookForParent(newlines,i)
            #first parent's child is the next for current item
            firstChild = newlines.index('-'*(currLevel-1)+parent)+1
            return string.lstrip(newlines[firstChild], '-')
        if level == currLevel:
            return string.lstrip(newlines[j], '-')

    for j in range(0, len(newlines)):
        level = GetLevel(newlines[j])
        if level == currLevel:
            return string.lstrip(newlines[j], '-')
开发者ID:grobza,项目名称:CMCG,代码行数:28,代码来源:CMCD.py

示例3: instantiate

 def instantiate(self, d):
     new_args = []
     for a in self.args:
         an = string.lstrip(string.lstrip(self.subject.name, "?"), "$")
         if not (an in d):
             new_args.append(a)
     return Query(self.prefs, new_args, self.body.instantiate(d), self.distinct)
开发者ID:victoriachenwu,项目名称:anapsid,代码行数:7,代码来源:services.py

示例4: dump_inter_dep

def dump_inter_dep(pathF, pathP):
    logF = open(pathF, "r")
    logP = open(pathP, "w")
    pFrame = 0
    while True:
        aLine = logF.readline()
        if (aLine == ""):
            break
        if ("+" in aLine):
            pFrame = 0
            tokens = re.split(":", aLine)
            if ("65" in tokens[1]):
                #it's P frame
                pFrame = string.atoi(string.lstrip(tokens[0], "+"))
                
        if (pFrame == 0):
            #skip all I-frames
            continue
        if ("&&&" in aLine) :
            #the motion estimation dependency
            writeStr = str(pFrame) + ":" + string.lstrip(aLine, "&")
            logP.write(writeStr)
            continue
    logF.close()
    logP.close()
开发者ID:DastanIqbal,项目名称:ffmpeg-with-selective-decoding,代码行数:25,代码来源:logdep.py

示例5: logProject

    def logProject(self, gitdir, projectname, year=None, projectdesc=None, county=None):
        """
        Figures out the commit string and the tag.  Subclass should figure out the rest.
        Returns the SHA1 hash ID of the git commit of the project applied
        """
        commitstr = self.getCommit(gitdir)
        tag       = self.getTags(gitdir, commitstr)

        if year:
            yearstr = "%4d" % year
        else:
            yearstr = "    "

        WranglerLogger.info("%-4s | %-5s | %-40s | %-40s | %-10s | %s" %
                            (yearstr,
                             tag if tag else "notag",
                             commitstr if commitstr else "",
                             string.lstrip(projectname) if projectname else "",
                             string.lstrip(county) if county else "",
                             string.lstrip(projectdesc) if projectdesc else ""
                             )
                            )
        self.appliedProjects[projectname] = tag if tag else commitstr
        
        return commitstr
开发者ID:bhargavasana,项目名称:NetworkWrangler,代码行数:25,代码来源:Network.py

示例6: getctrldir

def getctrldir(readin,jobid):
	setting={}
	molset = readin #open(sys.argv[1],'rt').read()
	molset= re.sub("@ ?",'\n',molset)
	exec(molset)
	setting['ATOM___']=atom
	setting['PZ___']= pz
	setting['FSMOM___']='%d' % fsmom
	setting['ALAT___']= '%9.4f' % alat
	rmt = discenter/2.0*rstar
	rsmh= rmt/2.0 
	eh_c =' %3.1f'   % eh  # converted to char
	eh2_c=' %3.1f'   % eh2
	rsmh_c= ' %3.3f' % max(rsmh,0.5)
	setting['RMT___']=' %3.3f' % rmt
	setting['EH___']   =' EH='  +4*eh_c
	setting['EH2___']  ='EH2='  +4*eh2_c

	dname1 = dirhead  + setout(setting,'ATOM___') \
	    +',fsmom=' + setout(setting,'FSMOM___') \
	    +',alat=' + setout(setting,'ALAT___')
	dname2 = \
	    'rmt='+ setout(setting,'RMT___') \
	    + ',EH=' + string.lstrip(eh_c) +  ',EH2='+ string.lstrip(eh2_c) \
	    + ',' + setout(setting,'PZ___')+','
        return dname1,dname2
开发者ID:Bakhtatou,项目名称:ecalj,代码行数:26,代码来源:jobatom1.py

示例7: dump_gop_rec

def dump_gop_rec(pathF, pathP):
    logF = open(pathF, "r")
    logP = open(pathP, "w")
    iFrame = 0
    pFrame = 0
    gopStarted = 0
    totalFrameNum = 0
    while True:
      aLine = logF.readline()
      if (aLine == ""):
        break
      if ("+" in aLine):
	tokens = re.split(":", aLine)
	if ("1" in tokens[1]):
	    iFrame = string.atoi(string.lstrip(tokens[0], "+"))
	    totalFrameNum = totalFrameNum + 1
	    if (gopStarted == 0):
		logP.write(str(iFrame) + ":")
		gopStarted = 1
	    else:
		logP.write(str(iFrame-1) + ":\n")
		logP.write(str(iFrame) + ":")
        if ("65" in tokens[1]):
            #it's p frame
            pFrame = string.atoi(string.lstrip(tokens[0], "+"))
            totalFrameNum = totalFrameNum + 1
            #print pFrame
    logP.write(str(totalFrameNum) + ":\n")
    logF.close()
    logP.close()
开发者ID:DastanIqbal,项目名称:ffmpeg-with-selective-decoding,代码行数:30,代码来源:logdep.py

示例8: autoindent

	def autoindent(self, command):
		# Extremely basic autoindenting.   Needs more work here.
		indent = len(command) - len(string.lstrip(command))
		if string.lstrip(command):
			self.text.insert("insert", command[:indent])
			if string.rstrip(command)[-1] == ":":
				self.text.insert("insert", "    ")
开发者ID:RJVB,项目名称:xgraph,代码行数:7,代码来源:Console.py

示例9: strip_opening_quotes

def strip_opening_quotes(s):
    s = lstrip(s)
    s = lstrip(s, '"')
    s = lstrip(s)
    s = lstrip(s, "'")
    s = lstrip(s)
    return s
开发者ID:sclaughl,项目名称:biblequiz-helps,代码行数:7,代码来源:master_processor.py

示例10: instantiateFilter

 def instantiateFilter(self, d, filter_str):
     new_args = []
     for a in self.args:
         an = string.lstrip(string.lstrip(self.subject.name, "?"), "$")
         if not (an in d):
             new_args.append(a)
     return Query(self.prefs, new_args, self.body, self.distinct, self.filter_nested + ' ' + filter_str)
开发者ID:gmontoya,项目名称:lilac,代码行数:7,代码来源:services.py

示例11: getInfoIO

 def getInfoIO(self, query):
     subquery = self.service.getTriples()
     vars_order_by=[x for v in query.order_by for x in v.getVars() ]
     vs = list(set(self.service.getVars()))# - set(self.service.filters_vars)) # Modified this by mac: 31-01-2014
     #print "service", vs, self.service.filters_vars
     predictVar=set(self.service.getPredVars())
     variables = [string.lstrip(string.lstrip(v, "?"), "$") for v in vs]
     if query.args == []:
         projvars = vs
     else:
         projvars = list(set([v.name for v in query.args if not v.constant]))
     subvars = list((query.join_vars | set(projvars)) & set(vs) )
     if subvars == []:
       subvars=vs
     subvars = list(set(subvars) | predictVar | set(vars_order_by))
     # This corresponds to the case when the subquery is the same as the original query.
     # In this case, we project the variables of the original query.
     if query.body.show(" ").count("SERVICE") == 1:
       subvars = list(set(projvars) | set(vars_order_by)) 
     
     subvars = string.joinfields(subvars, " ")
     #MEV distinct pushed down to the sources
     if query.distinct:
         d = "DISTINCT "
     else:
         d = ""
     
     subquery = "SELECT "+d+ subvars + " WHERE {" + subquery + "\n" + query.filter_nested + "\n}"
     return (self.service.endpoint, query.getPrefixes()+subquery, set(variables))
开发者ID:anapsid,项目名称:anapsid,代码行数:29,代码来源:Tree.py

示例12: getCount

    def getCount(self, query, vars, endpointType):
        subquery = self.service.getTriples()
        if len(vars) == 0:
            vs = self.service.getVars()
            variables = [string.lstrip(string.lstrip(v, "?"), "$") for v in vs]
            vars_str = "*"
        else:
            variables = vars
            service_vars = self.service.getVars()
            vars2 = []
            for v1 in vars:
                for v2 in service_vars:
                    if (v1 == v2[1:]):
                        vars2.append(v2)
                        break
            if len(vars2) > 0:
                vars_str = string.joinfields(vars2, " ")
            else:
                vars_str = "*"

        d = "DISTINCT "
        if (endpointType=="V"):
             subquery = "SELECT COUNT "+d+ vars_str + "  WHERE {" + subquery + "\n"+ query.filter_nested +"}"
        else:
            subquery = "SELECT ( COUNT ("+d+ vars_str + ") AS ?cnt)  WHERE {" + subquery +"\n"+ query.filter_nested + "}"
        return (self.service.endpoint, query.getPrefixes()+subquery)
开发者ID:anapsid,项目名称:anapsid,代码行数:26,代码来源:Tree.py

示例13: search_filename

def search_filename(filename, languages):
    title, year = xbmc.getCleanMovieTitle(filename)
    log(__name__, "clean title: \"%s\" (%s)" % (title, year))
    try:
        yearval = int(year)
    except ValueError:
        yearval = 0
    if title and yearval > 1900:
        search_string = title + "+" + year
        search_argenteam_api(search_string)
    else:
        match = re.search(
            r'\WS(?P<season>\d\d)E(?P<episode>\d\d)',
            title,
            flags=re.IGNORECASE
        )
        if match is not None:
            tvshow = string.strip(title[:match.start('season')-1])
            season = string.lstrip(match.group('season'), '0')
            episode = string.lstrip(match.group('episode'), '0')
            search_string = "%s S%#02dE%#02d" % (
                tvshow,
                int(season),
                int(episode)
            )
            search_argenteam_api(search_string)
        else:
            search_argenteam_api(filename)
开发者ID:estemendoza,项目名称:service.subtitles.argenteam,代码行数:28,代码来源:service.py

示例14: location

 def location(self):
     for env_variable in self.container_info['Config']['Env']:
         if re.search('ETCD_SERVICES', env_variable):
             return os.path.join('/services', \
                             string.lstrip( string.split( env_variable, '=' )[1].strip(), '/'), \
                             string.lstrip( self.container_info['Name'], '/'))
     return ''
开发者ID:jyidiego,项目名称:fleet-redis-demo,代码行数:7,代码来源:soa.py

示例15: start_logging

  def start_logging(self):

    # Register Ctrl+C handler so that we can gracefully logout
    signal.signal(signal.SIGINT, self.stop_logging)

    while(1):
      data = self.IRCsock.recv(2048)
      print data
      msg = string.split(data)
      #print msg

      # Handle Alive state
      if msg[0] == "PING":
        self.irc_send_command("PONG %s" % msg[1])

      # Handle private messages to bot
      if ('PRIVMSG' == msg[1]  and self.NICKNAME == msg[2] ) or ('PRIVMSG' == msg[1] and self.LOGCHANNEL == msg[2] and self.NICKNAME == string.strip(msg[3], ':,')):
        self.nick_name = string.lstrip(msg[0][:string.find(msg[0],"!")], ':')
        self.privmsg = ":Heya there! I'm LoggerBot, Do Not Disturb Me!"
        self.irc_send_command("PRIVMSG %s %s" % (self.nick_name, self.privmsg))

      # Actual logging of channel
      if msg[1] == "PRIVMSG" and msg[2] == self.LOGCHANNEL:
        self.logfile = open("/tmp/channel.log", "a+")
        self.nick_name = msg[0][:string.find(msg[0],"!")]

        timenow = self.convert_utc2local(strftime("%Y-%m-%d %H:%M:%S", gmtime()), 'Asia/Kolkata')
        message = ' '.join(msg[3:])
        self.logfile.write(timenow + " " + string.lstrip(self.nick_name, ':') + ' -> '     + string.lstrip(message, ':') + '\n')
        self.logfile.flush()
开发者ID:ReverseBitCoders,项目名称:IRCLogger,代码行数:30,代码来源:IRCLogger.py


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