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


Python string.upper函数代码示例

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


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

示例1: getfingerprint

  def getfingerprint(self,digest='md5',delimiter=':'):
    digest = string.upper(digest)
    if not digest in ['MD2','MD5','MDC2','RMD160','SHA','SHA1']:
      raise ValueError, 'Illegal parameter for digest: %s' % digest
    elif self.fingerprint.has_key(digest):
      result = self.fingerprint[digest]
    elif digest=='MD5':
      return certhelper.MD5Fingerprint(certhelper.pem2der(open(self.filename,'r').read()),delimiter)
    elif digest=='SHA1':
      return certhelper.SHA1Fingerprint(certhelper.pem2der(open(self.filename,'r').read()),delimiter)
    else:
      opensslcommand = '%s x509 -in %s -inform %s -outform DER | %s %s' % (
        openssl.bin_filename,
        self.filename,
        self.format,
        openssl.bin_filename,
        string.lower(digest)
      )
      f = os.popen(opensslcommand)
      rawdigest = string.strip(f.read())
      rc = f.close()
      if rc and rc!=256:
	raise IOError,"Error %s: %s" % (rc,opensslcommand)
      result = []
      for i in range(len(rawdigest)/2):
        result.append(rawdigest[2*i:2*(i+1)])
      self.fingerprint[digest] = result
    return string.upper(string.join(result,delimiter))
开发者ID:joshuacoddingyou,项目名称:python,代码行数:28,代码来源:cert.py

示例2: Dependencies

def Dependencies(lTOC):
    """Expand LTOC to include all the closure of binary dependencies.

     LTOC is a logical table of contents, ie, a seq of tuples (name, path).
     Return LTOC expanded by all the binary dependencies of the entries
     in LTOC, except those listed in the module global EXCLUDES"""
    for (nm, pth) in lTOC:
        fullnm = string.upper(os.path.basename(pth))
        if seen.get(string.upper(nm), 0):
            continue
        print "analyzing", nm
        seen[string.upper(nm)] = 1
        dlls = getImports(pth)
        for lib in dlls:
            print " found", lib
            if excludes.get(string.upper(lib), 0):
                continue
            if seen.get(string.upper(lib), 0):
                continue
            npth = getfullnameof(lib)
            if npth:
                lTOC.append((lib, npth))
            else:
                print " lib not found:", lib, "dependency of",
    return lTOC
开发者ID:lolman8776,项目名称:ToontownInfinite,代码行数:25,代码来源:bindepend.py

示例3: match

    def match(self, pattern, that, topic):
        """Return the template which is the closest match to pattern. The
        'that' parameter contains the bot's previous response. The 'topic'
        parameter contains the current topic of conversation.

        Returns None if no template is found.
        
        """
        if len(pattern) == 0:
            return None
        pattern = self._lang_support(pattern)
        # Mutilate the input.  Remove all punctuation and convert the
        # text to all caps.
        input = string.upper(pattern)
        input = self._puncStripRE.sub("", input)
        input = self._upuncStripRE.sub(u"", input)
        #print input
        if that.strip() == u"": that = u"ULTRABOGUSDUMMYTHAT" # 'that' must never be empty
        thatInput = string.upper(that)
        thatInput = re.sub(self._whitespaceRE, " ", thatInput)
        thatInput = re.sub(self._puncStripRE, "", thatInput)
        if topic.strip() == u"": topic = u"ULTRABOGUSDUMMYTOPIC" # 'topic' must never be empty
        topicInput = string.upper(topic)
        topicInput = re.sub(self._puncStripRE, "", topicInput)
        
        # Pass the input off to the recursive call
        patMatch, template = self._match(input.split(), thatInput.split(), topicInput.split(), self._root)
        return template
开发者ID:AaronZhangL,项目名称:Talkbot,代码行数:28,代码来源:PatternMgr.py

示例4: cnToUser

def cnToUser(cn):
    components = split_re.split(cn)
    max_score = 0
    best = None
    for component in components:
        score = 0
        if all_numbers.match(component):
            continue
        len_score = len(component.split())
        if len_score == 1:
            len_score = len(component.split('-'))
        score += len_score
        if score > max_score:
            best = component
            max_score = score
    if max_score == 0:
        best = component[-1]
    result = []
    for word in best.split():
        word_0 = string.upper(word[0])
        word_rest = string.lower(word[1:])
        word_rest2 = string.upper(word[1:])
        if word[1:] == word_rest2:
            word = word_0 + word_rest
        else:
            word = word_0 + word[1:]
        if not all_numbers.match(word):
            result.append(word)
    result = ' '.join(result)
    return result
开发者ID:YalingZheng,项目名称:CombinedXrootdReport,代码行数:30,代码来源:report_cmsxrootd.py

示例5: Dependencies

def Dependencies(lTOC):
  """Expand LTOC to include all the closure of binary dependencies.
  
     LTOC is a logical table of contents, ie, a seq of tuples (name, path).
     Return LTOC expanded by all the binary dependencies of the entries
     in LTOC, except those listed in the module global EXCLUDES"""
  for nm, pth, typ in lTOC:
    fullnm = string.upper(os.path.basename(pth))
    if seen.get(string.upper(nm),0):
      continue
    #print "I: analyzing", pth
    seen[string.upper(nm)] = 1
    dlls = getImports(pth)
    for lib in dlls:
        #print "I: found", lib
        if not iswin and not cygwin:
            npth = lib
            dir, lib = os.path.split(lib)
            if excludes.get(dir,0):
                continue
        if excludes.get(string.upper(lib),0):
            continue
        if seen.get(string.upper(lib),0):
            continue
        if iswin or cygwin:
            npth = getfullnameof(lib, os.path.dirname(pth))
        if npth:
            lTOC.append((lib, npth, 'BINARY'))
        else:
            print "E: lib not found:", lib, "dependency of", pth
  return lTOC
开发者ID:pombreda,项目名称:comp304,代码行数:31,代码来源:bindepend.py

示例6: get_capi_name

def get_capi_name(cppname, isclassname, prefix = None):
    """ Convert a C++ CamelCaps name to a C API underscore name. """
    result = ''
    lastchr = ''
    for chr in cppname:
        # add an underscore if the current character is an upper case letter
        # and the last character was a lower case letter
        if len(result) > 0 and not chr.isdigit() \
            and string.upper(chr) == chr \
            and not string.upper(lastchr) == lastchr:
            result += '_'
        result += string.lower(chr)
        lastchr = chr
    
    if isclassname:
        result += '_t'
        
    if not prefix is None:
        if prefix[0:3] == 'cef':
            # if the prefix name is duplicated in the function name
            # remove that portion of the function name
            subprefix = prefix[3:]
            pos = result.find(subprefix)
            if pos >= 0:
                result = result[0:pos]+ result[pos+len(subprefix):]
        result = prefix+'_'+result
        
    return result
开发者ID:angrymango,项目名称:CEF,代码行数:28,代码来源:cef_parser.py

示例7: check_variable_len_bcs_dups

def check_variable_len_bcs_dups(header, mapping_data, errors):
    """ Checks variable length barcodes plus sections of primers for dups
    
    header:  list of header strings
    mapping_data:  list of lists of raw metadata mapping file data
    errors:  list of errors
    """

    header_field_to_check = "BarcodeSequence"

    # Skip if no field BarcodeSequence
    try:
        check_ix = header.index(header_field_to_check)
    except ValueError:
        return errors

    linker_primer_field = "LinkerPrimerSequence"

    try:
        linker_primer_ix = header.index(linker_primer_field)
        no_primers = False
    except ValueError:
        no_primers = True

    barcodes = []
    bc_lens = []

    correction = 1

    for curr_data in mapping_data:
        barcodes.append(upper(curr_data[check_ix]))
        bc_lens.append(len(curr_data[check_ix]))

    # Get max length of barcodes to determine how many primer bases to slice
    barcode_max_len = max(bc_lens)

    # Have to do second pass to append correct number of nucleotides to
    # check for duplicates between barcodes and primer sequences

    bcs_added_nts = []
    for curr_data in mapping_data:
        if no_primers:
            bcs_added_nts.append(upper(curr_data[check_ix]))
        else:
            adjusted_len = barcode_max_len - len(curr_data[check_ix])
            bcs_added_nts.append(upper(curr_data[check_ix] + curr_data[linker_primer_ix][0:adjusted_len]))

    dups = duplicates_indices(bcs_added_nts)

    for curr_dup in dups:
        for curr_loc in dups[curr_dup]:
            if no_primers:
                errors.append("Duplicate barcode %s found.\t%d,%d" % (curr_dup, curr_loc + correction, check_ix))
            else:
                errors.append(
                    "Duplicate barcode and primer fragment sequence "
                    + "%s found.\t%d,%d" % (curr_dup, curr_loc + correction, check_ix)
                )

    return errors
开发者ID:qinjunjie,项目名称:qiime,代码行数:60,代码来源:check_id_map.py

示例8: read_DNA_sequence

 def read_DNA_sequence(self,filename):
     #
     # Read the sequence
     #
     fd=open(filename)
     lines=fd.readlines()
     fd.close()
     #for line in lines:
     #    print line,
     #
     # Figure out what kind of file it is - a bit limited at the moment
     #
     import string
     if lines[0][0]=='>' and string.upper(lines[0][1:3])!='DL':
         # FASTA
         #print 'Reading FASTA'
         return self.readfasta(filename)
     elif string.upper(lines[0][:3])=='>DL':
         # PIR
         #print 'READING pir'
         return self.readpir(filename)
     elif string.upper(lines[0][:5])=='LOCUS':
         # GenBank
         #print 'READING Genbank'
         return self.readGenBank(filename)
     elif lines[0][2:5]=='xml':
         for line in lines:
             if string.find(line,'DOCTYPE Bsml')!=-1:
                 return self.readBSML(filename)
         return None
     else:
         # FLAT file
         #print 'READING FLAT'
         return self.readflat(filename)
开发者ID:shambo001,项目名称:peat,代码行数:34,代码来源:DNA_sequence.py

示例9: initialize

   def initialize(self):
      self.d = {}
      with open("saltUI/ciphersuites.txt") as f:
         for line in f:
            (key, val, sec) = line.split()
            self.d[key] = val + " (" + sec + ")"
      
      self.pr = {
         6: "TCP",
         17: "UDP"
         }
      with open("data/ip.txt") as f:
         for line in f:
            (key, val) = line.split()
            self.pr[key] = val

      self.ports = {}
      with open("data/ports.txt") as f:
         for line in f:
            try:
               (val, key) = line.split()
               if '-' in str(key):
                  start, stop = str(key).split('-')
                  for a in range(int(start), int(stop)):
                     self.ports[a] = string.upper(val)
               else:
                  key = int(key)
                  self.ports[key] = string.upper(val)
            except:
               pass
开发者ID:houcy,项目名称:joy,代码行数:30,代码来源:query.py

示例10: walk_directory

def walk_directory(prefix=""):
    views = []
    sections = []

    for dirname, dirnames, filenames in os.walk("."):

        for filename in filenames:

            filepart, fileExtension = os.path.splitext(filename)
            pos = filepart.find("ViewController")
            if string.lower(fileExtension) == ".xib" and pos > 0:
                # read file contents
                f = open(dirname + "/" + filename, "r")
                contents = f.read()
                f.close()

                # identify identifier part
                vc_name = prefix_remover(filepart[0:pos], prefix)
                vc_name = special_names(vc_name)

                if (
                    string.find(contents, "MCSectionViewController") != -1
                    or string.find(contents, "RFSectionViewController") != -1
                    or string.find(contents, "SectionViewController") != -1
                ):
                    sections.append(
                        {"type": "section", "variable_name": "SECTION_" + string.upper(vc_name), "mapped_to": filepart}
                    )
                else:
                    views.append(
                        {"type": "view", "variable_name": "VIEW_" + string.upper(vc_name), "mapped_to": filepart}
                    )

    return sections, views
开发者ID:rhfung,项目名称:RFViewFactory,代码行数:34,代码来源:createviews.py

示例11: game

def game(word2):
    i=0
    while (i+1)<len(word2): # This loop finds the double letters (ie. 'll' or 'tt') in the inputed word.
        if word2[i]==word2[i+1]:
            print "Yes, Grandma does like %s." %(string.upper(word2))
            time.sleep(.5)
            word3=raw_input ('What else does she like? ')
            time.sleep(.5)
            i=len(word2)-2
            if word3!="DONE":
               game(word3)
            else:
                print "Thanks for playing!"
            return
        if word2[i]!=word2[i+1]:
            i=i+1
    b=random.randrange(0,16)
    likes=["sinners", "winners", "Mommy", "little", "tall", "Harry","kittens", "all", "books", "trees", "bees", "yellow", "jello", "good", "kisses", "wrapping paper", "the moon", "yellow"]
    dislikes=["saints", "losers", "Mother","big", "short", "Ron", "cats", "none", "magazines", "flowers", "ladybugs", "white", "fudge", "bad", "hugs","gift bags", "the sun", "white"]
    c=likes[b]
    d=dislikes[b]
    print "No, Grandma doesn't like %s." %(string.upper(word2)) # This prints a random set of examples.
    time.sleep(.5)
    print 'She likes %s but not %s.'  %(string.upper(c),string.upper(d))
    time.sleep(.5)
    word3=raw_input ("What else does she like? ")
    time.sleep(.5)
    if word3!="DONE":
        game(word3)
    else:
        print "Thanks for playing!"
开发者ID:keriwheatley,项目名称:projectGrandmaGame,代码行数:31,代码来源:games.py

示例12: do_GET

    def do_GET(self):
        self.send_response(200)  # Return a response of 200, OK to the client
        self.end_headers()
        parsed_path = urlparse.urlparse(self.path)

        if upper(parsed_path.path) == "/KILL_TASK":
            try:
                obsnum = str(parsed_path.query)
                pid_of_obs_to_kill = int(self.server.dbi.get_obs_pid(obsnum))
                logger.debug("We recieved a kill request for obsnum: %s, shutting down pid: %s" % (obsnum, pid_of_obs_to_kill))
                self.server.kill(pid_of_obs_to_kill)
                self.send_response(200)  # Return a response of 200, OK to the client
                self.end_headers()
                logger.debug("Task killed for obsid: %s" % obsnum)
            except:
                logger.exception("Could not kill observation, url path called : %s" % self.path)
                self.send_response(400)  # Return a response of 200, OK to the client
                self.end_headers()
        elif upper(parsed_path.path) == "/INFO_TASKS":
            task_info_dict = []
            for mytask in self.server.active_tasks:  # Jon : !!CHANGE THIS TO USE A PICKLED DICT!!
                try:
                    child_proc = mytask.process.children()[0]
                    if psutil.pid_exists(child_proc.pid):
                        task_info_dict.append({'obsnum': mytask.obs, 'task': mytask.task, 'pid': child_proc.pid,
                                               'cpu_percent': child_proc.cpu_percent(interval=1.0), 'mem_used': child_proc.memory_info_ex()[0],
                                               'cpu_time': child_proc.cpu_times()[0], 'start_time': child_proc.create_time(), 'proc_status': child_proc.status()})
                except:
                    logger.exception("do_GET : Trying to send response to INFO request")
            pickled_task_info_dict = pickle.dumps(task_info_dict)
            self.wfile.write(pickled_task_info_dict)

        return
开发者ID:pkgw,项目名称:hera-real-time-pipe,代码行数:33,代码来源:task_server.py

示例13: __init__

 def __init__(self, r, s):
     """where r is the rank, s is suit"""
     if type(r) == str:
         r = string.upper(r)
     self.r = r
     s = string.upper(s)
     self.s = s
开发者ID:jonathanlerner,项目名称:Penn-Eng,代码行数:7,代码来源:cards.py

示例14: readMeAConfigPortion

def readMeAConfigPortion(fd,patterns):
    pos = fd.tell()
    data = fd.readline()
    while (string.strip(data) == '') or (data[0]=='#'):
        data = fd.readline()
        #print " [replaced by ",fd.tell(),"] ",data
        if data == '':
            return (None,"End-of-file")
    print "WORKING (at",pos,") ",data,
    endoflinepos = fd.tell()
    for p in patterns:
        if type(p) == type(""):
            print " --> Does <<",string.strip(data),">> match",p,"?"
            if string.upper(data[:len(p)])==string.upper(p):
                print "       yes, it does match ",p,"!"
                return (p,string.strip(data[len(p):]))
        elif callable(p):
            print " --> Does <<",string.strip(data),">> match",repr(p),"?"
            try:
                fd.seek(pos)
                x = p(fd)
                print "      yes it does match ",repr(p),"!"
                return (p,x)
            except notOneOfTheseThanks:
                fd.seek(endoflinepos)
                continue
    print " Sadly,  no,  <<",string.strip(data),">> does not match any of",repr(patterns)
    fd.seek(pos)
    return (None,None)
开发者ID:solresol,项目名称:rafads,代码行数:29,代码来源:rafads.py

示例15: translate

def translate(DNA_sequence):
    """Translate the DNA sequence in three forward frames"""
    #
    # Check the sequence first
    #
    ok,DNA_sequence=check_DNA(DNA_sequence)
    if not ok:
        print
        print 'DNA sequence not ok'
        print DNA_sequence
        print
        return None
    #
    # Translate
    #
    import string
    translation_3=[]
    translation_1=[]
    for start in range(3):
        position=start
        thisAA=''
        thisframe3=[]
        thisframe1=''
        while position<len(DNA_sequence):
            thisAA=thisAA+DNA_sequence[position]
            position=position+1
            if len(thisAA)==3:
                thisframe1=thisframe1+three_to_one[string.upper(genetic_code[thisAA])]
                thisframe3.append(string.upper(genetic_code[thisAA]))
                thisAA=''
        translation_3.append(thisframe3)
        translation_1.append(thisframe1)
    return translation_3,translation_1
开发者ID:shambo001,项目名称:peat,代码行数:33,代码来源:Mutation.py


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