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


Python string.rfind方法代码示例

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


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

示例1: parseJavaScriptCalls

# 需要导入模块: import string [as 别名]
# 或者: from string import rfind [as 别名]
def parseJavaScriptCalls():
	global database_js
	"""
		Parse the JavaScript and download the files
	"""
	for j in database_js:
		jsName = j[j.rfind('/')+1:]
		if not os.path.exists('local/js/' + jsName):
			# first download the file
			dl(j,'local/js/' + jsName)
			try:
				jsContent = open('local/js/' + jsName, 'r')
			except IOError:
				continue
			parseJavaScriptContent(jsContent)
			jsContent.close() 
开发者ID:penetrate2hack,项目名称:ITWSV,代码行数:18,代码来源:spider.py

示例2: printexpr

# 需要导入模块: import string [as 别名]
# 或者: from string import rfind [as 别名]
def printexpr(expr_string):
    """ printexpr(expr) - 
        print the value of the expression, along with linenumber and filename.
    """

    stack = extract_stack ( )[-2:][0]
    actualCall = stack[3]
    left = string.find ( actualCall, '(' )
    right = string.rfind ( actualCall, ')' )
    caller_globals,caller_locals = _caller_symbols()
    expr = eval(expr_string,caller_globals,caller_locals)
    varType = type( expr )
    stderr.write("%s:%d>  %s == %s  (%s)\n" % (
        stack[0], stack[1],
        string.strip( actualCall[left+1:right] )[1:-1],
        repr(expr), str(varType)[7:-2])) 
开发者ID:ActiveState,项目名称:code,代码行数:18,代码来源:recipe-52278.py

示例3: lineReceived

# 需要导入模块: import string [as 别名]
# 或者: from string import rfind [as 别名]
def lineReceived(self, line):
        parts = string.split(line)
        if not parts:
            parts = ['']
        if len(parts) == 1:
            slash_w = 0
        else:
            slash_w = 1
        user = parts[-1]
        if '@' in user:
            host_place = string.rfind(user, '@')
            user = user[:host_place]
            host = user[host_place+1:]
            return self.forwardQuery(slash_w, user, host)
        if user:
            return self.getUser(slash_w, user)
        else:
            return self.getDomain(slash_w) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:20,代码来源:finger.py

示例4: _fixupParents

# 需要导入模块: import string [as 别名]
# 或者: from string import rfind [as 别名]
def _fixupParents(self, alogger):
        """
        Ensure that there are either loggers or placeholders all the way
        from the specified logger to the root of the logger hierarchy.
        """
        name = alogger.name
        i = string.rfind(name, ".")
        rv = None
        while (i > 0) and not rv:
            substr = name[:i]
            if not self.loggerDict.has_key(substr):
                self.loggerDict[substr] = PlaceHolder(alogger)
            else:
                obj = self.loggerDict[substr]
                if isinstance(obj, Logger):
                    rv = obj
                else:
                    assert isinstance(obj, PlaceHolder)
                    obj.append(alogger)
            i = string.rfind(name, ".", 0, i - 1)
        if not rv:
            rv = self.root
        alogger.parent = rv 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:25,代码来源:__init__.py

示例5: fetch

# 需要导入模块: import string [as 别名]
# 或者: from string import rfind [as 别名]
def fetch(file):
   if base_url in file:
      dir = file[len(base_url) - 1:rfind(file, '/') + 1]
      file = file[rfind(file, '/') + 1:]
   elif 'http' in file:
      return
   else:
      dir = '/'
   process(dir + file)
   base_dir = path.dirname(dir + file)
   if base_dir != '/':
      base_dir += '/'
   tree = ElementTree.parse(out_dir + dir + file)
   for element in tree.getiterator():
      if element.tag.split('}')[1] == 'url':
         if element.text[-4:] != '.xml':
            if not 'http' in element.text:
               process(base_dir + element.text)
         else:
            fetch(element.text) 
开发者ID:opencas,项目名称:mirrord,代码行数:22,代码来源:android.py

示例6: makeRoot

# 需要导入模块: import string [as 别名]
# 或者: from string import rfind [as 别名]
def makeRoot(urlLocal):
	if allowedExtensions(urlLocal):
		return urlLocal[0:urlLocal.rfind('/')+1]
	return urlLocal 
开发者ID:penetrate2hack,项目名称:ITWSV,代码行数:6,代码来源:spider.py

示例7: giveGoodURL

# 需要导入模块: import string [as 别名]
# 或者: from string import rfind [as 别名]
def giveGoodURL(href, urlLocal):
	"""
		It should return a good url...
		href = argument retrieven from the href...
	"""
	if 'javascript' in href:
		return htmldecode(urlLocal)
	if 'http://' in href or 'https://' in href:
		if urlLocal in href:
			return htmldecode(href)
		else:
			return urlLocal
	if len(href) < 1:
		return htmldecode(urlLocal)
	if href[0] == '?' and '?' not in urlLocal and not allowedExtensions(urlLocal):
		for e in allowed:
			if '.'+e in urlLocal:
				return htmldecode(urlLocal + href)
		return htmldecode(urlLocal + '/' + href)
	else:
		# simple name
		if allowedExtensions(urlLocal) or '?' in urlLocal:
			return htmldecode(urlLocal[0:urlLocal.rfind('/')+1] + href)
		else:
			return htmldecode(urlLocal + '/' + href)
	return htmldecode(href) 
开发者ID:penetrate2hack,项目名称:ITWSV,代码行数:28,代码来源:spider.py

示例8: rfindFirstJSChars

# 需要导入模块: import string [as 别名]
# 或者: from string import rfind [as 别名]
def rfindFirstJSChars(string):
	b = [string.rfind(k) for k in jsChars]
	return max(b) 
开发者ID:penetrate2hack,项目名称:ITWSV,代码行数:5,代码来源:spider.py

示例9: collectintargz

# 需要导入模块: import string [as 别名]
# 或者: from string import rfind [as 别名]
def collectintargz(target, source, env):
    """ Puts all source files into a tar.gz file. """
    # the rpm tool depends on a source package, until this is chagned
    # this hack needs to be here that tries to pack all sources in.
    sources = env.FindSourceFiles()

    # filter out the target we are building the source list for.
    #sources = [s for s in sources if not (s in target)]
    sources = filter(lambda s, t=target: not (s in t), sources)

    # find the .spec file for rpm and add it since it is not necessarily found
    # by the FindSourceFiles function.
    #sources.extend( [s for s in source if str(s).rfind('.spec')!=-1] )
    spec_file = lambda s: string.rfind(str(s), '.spec') != -1
    sources.extend( filter(spec_file, source) )

    # as the source contains the url of the source package this rpm package
    # is built from, we extract the target name
    #tarball = (str(target[0])+".tar.gz").replace('.rpm', '')
    tarball = string.replace(str(target[0])+".tar.gz", '.rpm', '')
    try:
        #tarball = env['SOURCE_URL'].split('/')[-1]
        tarball = string.split(env['SOURCE_URL'], '/')[-1]
    except KeyError as e:
        raise SCons.Errors.UserError( "Missing PackageTag '%s' for RPM packager" % e.args[0] )

    tarball = src_targz.package(env, source=sources, target=tarball,
                                PACKAGEROOT=env['PACKAGEROOT'], )

    return (target, tarball) 
开发者ID:coin3d,项目名称:pivy,代码行数:32,代码来源:rpm.py

示例10: rightmost_separator

# 需要导入模块: import string [as 别名]
# 或者: from string import rfind [as 别名]
def rightmost_separator(path, sep, _altsep=_altsep):
        rfind = string.rfind
        return max(rfind(path, sep), rfind(path, _altsep)) 
开发者ID:coin3d,项目名称:pivy,代码行数:5,代码来源:Util.py

示例11: splitext

# 需要导入模块: import string [as 别名]
# 或者: from string import rfind [as 别名]
def splitext(path):
    "Same as os.path.splitext() but faster."
    sep = rightmost_separator(path, os.sep)
    dot = string.rfind(path, '.')
    # An ext is only real if it has at least one non-digit char
    if dot > sep and not containsOnly(path[dot:], "0123456789."):
        return path[:dot],path[dot:]
    else:
        return path,"" 
开发者ID:coin3d,项目名称:pivy,代码行数:11,代码来源:Util.py

示例12: RegGetValue

# 需要导入模块: import string [as 别名]
# 或者: from string import rfind [as 别名]
def RegGetValue(root, key):
        """This utility function returns a value in the registry
        without having to open the key first.  Only available on
        Windows platforms with a version of Python that can read the
        registry.  Returns the same thing as
        SCons.Util.RegQueryValueEx, except you just specify the entire
        path to the value, and don't have to bother opening the key
        first.  So:

        Instead of:
          k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE,
                r'SOFTWARE\Microsoft\Windows\CurrentVersion')
          out = SCons.Util.RegQueryValueEx(k,
                'ProgramFilesDir')

        You can write:
          out = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE,
                r'SOFTWARE\Microsoft\Windows\CurrentVersion\ProgramFilesDir')
        """
        # I would use os.path.split here, but it's not a filesystem
        # path...
        p = key.rfind('\\') + 1
        keyp = key[:p-1]          # -1 to omit trailing slash
        val = key[p:]
        k = RegOpenKeyEx(root, keyp)
        return RegQueryValueEx(k,val) 
开发者ID:coin3d,项目名称:pivy,代码行数:28,代码来源:Util.py

示例13: my_import

# 需要导入模块: import string [as 别名]
# 或者: from string import rfind [as 别名]
def my_import(mname):
    if '.' in mname:
        i = string.rfind(mname, '.')
        parent = my_import(mname[:i])
        fp, pathname, description = imp.find_module(mname[i+1:],
                                                    parent.__path__)
    else:
        fp, pathname, description = imp.find_module(mname)
    return imp.load_module(mname, fp, pathname, description) 
开发者ID:coin3d,项目名称:pivy,代码行数:11,代码来源:sconsign.py

示例14: authentication_hash_validate

# 需要导入模块: import string [as 别名]
# 或者: from string import rfind [as 别名]
def authentication_hash_validate():
    """
    This function is called to check if a username /
    password combination is valid.
    """
    def last_occurence_delete(string, character):
        index = string.rfind(character)
        if index is None or index < 0:
            return string
        return string[:index] + string[index + 1:]

    hash_response = str(flask.request.headers.get('Authorization', ''))
    if len(hash_response) == 0:
        return False
    hash_challenge_list = []
    # Check normal url
    url = str(flask.request.url)
    hash_challenge = get_url_authorization(url)
    hash_challenge_list.append(hash_challenge)
    # If hash at the end of the url, try alternate hash as well
    url = last_occurence_delete(url, '/')
    hash_challenge = get_url_authorization(url)
    hash_challenge_list.append(hash_challenge)
    if '?' in url:
        url.replace('?', '/?')
        hash_challenge = get_url_authorization(url)
        hash_challenge_list.append(hash_challenge)
    return hash_response in hash_challenge_list 
开发者ID:Erotemic,项目名称:ibeis,代码行数:30,代码来源:controller_inject.py

示例15: parse_primitive_type

# 需要导入模块: import string [as 别名]
# 或者: from string import rfind [as 别名]
def parse_primitive_type(col):
    idx = string.find(col, '(')
    ridx = string.rfind(col, ')')
    if idx < 0 and ridx < 0:
        return [col]
    elif idx > 0 and ridx > 0:
        type = col[: idx].strip()
        specs = col[idx + 1 : ridx]
        specs = specs.split(',')
        specs = map(str.strip, specs)
        return [type, specs]
    else:
        raise RuntimeError("Invalid primitive type: " + col) 
开发者ID:exasol,项目名称:script-languages,代码行数:15,代码来源:datagen.py


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