本文整理汇总了Python中string.lstrip函数的典型用法代码示例。如果您正苦于以下问题:Python lstrip函数的具体用法?Python lstrip怎么用?Python lstrip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lstrip函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: constructmenuitemstring
def constructmenuitemstring(self,items,keybindingsdict):
def emptystring(num):
if num<=0:
return ""
return " "+emptystring(num-1)
if len(items)==1:
return items[0]
keykey=string.lstrip(string.rstrip(items[1]))
if keykey not in keybindingsdict:
ret = string.rstrip(items[0])
commands[string.lstrip(ret)] = string.lstrip(items[1])
return ret
key=keybindingsdict[keykey]
qualifier=""
for item in key[1]:
qualifier+=get_key_name(item)+" + "
#print "items[0]",items[0],len(items[0]),qualifier
stripped0 = string.rstrip(items[0])
ret = stripped0 + emptystring(41-len(stripped0)) + qualifier + get_key_name(key[0][0])
commands[string.lstrip(ret)] = string.lstrip(items[1])
return ret
开发者ID:jakobvonrotz,项目名称:radium,代码行数:26,代码来源:menues.py
示例17: get_dir
def get_dir(self, path, dest='', env='base', gzip=None):
'''
Get a directory recursively from the salt-master
'''
# TODO: We need to get rid of using the string lib in here
ret = []
# Strip trailing slash
path = string.rstrip(self._check_proto(path), '/')
# Break up the path into a list containing the bottom-level directory
# (the one being recursively copied) and the directories preceding it
separated = string.rsplit(path, '/', 1)
if len(separated) != 2:
# No slashes in path. (This means all files in env will be copied)
prefix = ''
else:
prefix = separated[0]
# Copy files from master
for fn_ in self.file_list(env):
if fn_.startswith(path):
# Prevent files in "salt://foobar/" (or salt://foo.sh) from
# matching a path of "salt://foo"
try:
if fn_[len(path)] != '/':
continue
except IndexError:
continue
# Remove the leading directories from path to derive
# the relative path on the minion.
minion_relpath = string.lstrip(fn_[len(prefix):], '/')
ret.append(
self.get_file(
'salt://{0}'.format(fn_),
'{0}/{1}'.format(dest, minion_relpath),
True, env, gzip
)
)
# Replicate empty dirs from master
try:
for fn_ in self.file_list_emptydirs(env):
if fn_.startswith(path):
# Prevent an empty dir "salt://foobar/" from matching a path of
# "salt://foo"
try:
if fn_[len(path)] != '/':
continue
except IndexError:
continue
# Remove the leading directories from path to derive
# the relative path on the minion.
minion_relpath = string.lstrip(fn_[len(prefix):], '/')
minion_mkdir = '{0}/{1}'.format(dest, minion_relpath)
if not os.path.isdir(minion_mkdir):
os.makedirs(minion_mkdir)
ret.append(minion_mkdir)
except TypeError:
pass
ret.sort()
return ret
开发者ID:joehealy,项目名称:pkg-salt,代码行数:59,代码来源:fileclient.py
示例18: assembleNode
def assembleNode(fout, nodeLines):
labelToAddr = {}
# scan for labels, removing them
for addr in range(len(nodeLines)):
line = string.lstrip(nodeLines[addr])
while 1:
m = re.match(r'(\w+):.*', line)
if not m: break
label = m.group(1)
labelToAddr[label] = addr
print "set %s to address %d" % (label, addr)
line = string.lstrip(line[len(label)+1:])
nodeLines[addr] = line
# add empty lines so that 15 instructions are assembled
if len(nodeLines) > 15:
raise Exception("node has more than 15 instructions!")
nodeLines = nodeLines + ([""] * (15-len(nodeLines)))
# now assemble
for line in nodeLines:
m = re.match(r'^(\w+) (.+?)(?:, (.+))?$', line)
if m:
mnem = m.group(1)
opers = list(m.group(2, 3))
opcode = None
if mnem in defs.opcStrToId:
opcode = defs.opcStrToId[mnem]
else:
raise Exception("unknown mnemonic \"%s\"" % mnem)
# map text operand to id
for i in range(len(opers)):
if opers[i] == None:
opers[i] = 0
elif re.match(r'-?\d+', opers[i]):
opers[i] = int(opers[i])
elif opers[i] in labelToAddr:
opers[i] = labelToAddr[opers[i]]
elif opers[i] in defs.operToId:
opers[i] = defs.operToId[opers[i]]
else:
print "illegal operand \"%s\"" % opers[i]
# write 'em
data = struct.pack('<Bhh', opcode, opers[0], opers[1])
fout.write(data)
elif re.match(r'^\s*$', line):
data = struct.pack('<BHH', OPCODE_NULL, 0, 0)
fout.write(data)
else:
print "syntax error for instruction \"%s\"" % line
sys.exit(-1)
开发者ID:lwerdna,项目名称:experiments,代码行数:59,代码来源:assembler.py
示例19: LookForParent
def LookForParent(newlines, i):
currLevel = GetLevel(newlines[i])
if currLevel==1:
return string.lstrip(newlines[i], '-')
for j in range(i-1, -1, -1):
level = GetLevel(newlines[j])
if level<currLevel:
return string.lstrip(newlines[j], '-')
开发者ID:grobza,项目名称:CMCG,代码行数:8,代码来源:CMCD.py
示例20: StripContMark
def StripContMark(self,line,line_num,col_num,next):
# continuation mark only if next line is a continued one
#if next!=self.NEW_STATEMENT:
contmatch = self.re_contmark.match(line)
if contmatch:
text = lstrip(contmatch.group())
self.AppendAttribute( ContMarker(text, (line_num, col_num)) )
line = lstrip(line)[1:]
return line
开发者ID:hiker,项目名称:stan,代码行数:9,代码来源:Scanner.py
注:本文中的string.lstrip函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论