本文整理汇总了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
示例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], '-')
示例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)
示例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()
示例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
示例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
示例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()
示例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", " ")
示例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
示例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)
示例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))
示例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)
示例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)
示例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 ''
示例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()