original_docstring: Add delimiters to single argument in function call.
docstring: Add delimiters to single argument in function call.
docstring_tokens: Add delimiters to single argument in function call .
code: def wrapArgInCall(source, callfn, wrapL, wrapR=None, argnums=[0],
                    notFirst=False):
      """Add delimiters to single argument in function call."""
      done = False
      output = ""
      currpos = 0
      first_occurrence = True
      if wrapR is None:
          # if no specific wrapR is specified, just use wrapL
          # e.g. for symmetric delimiters such as quotes
          wrapR = wrapL
      assert isinstance(wrapL, str) and isinstance(wrapR, str), \
             "Supplied delimiters must be strings"
      while not done:
          # find callfn in source
          findposlist = [source[currpos:].find(callfn+'(')]
          try:
              findpos = min([x for x in findposlist if x >= 0]) + currpos
          except ValueError:
              done = True
          if not done:
              # find start and end braces
              startbrace = source[findpos:].find('(')+findpos
              endbrace = findEndBrace(source[startbrace:])+startbrace
              output += source[currpos:startbrace+1]
              # if more than one argument present, apply wrapping to specified
              # arguments
              currpos = startbrace+1
              numargs = source[startbrace+1:endbrace].count(',')+1
              if max(argnums) >= numargs:
                  raise ValueError("Specified argument number out of range")
              if numargs > 1:
                  for argix in range(numargs-1):
                      nextcomma = source[currpos:endbrace].find(',')
                      argstr = source[currpos:currpos + nextcomma]
                      # get rid of leading or tailing whitespace
                      argstr = argstr.strip()
                      if argix in argnums:
                          if first_occurrence and notFirst:
                              output += source[currpos:currpos + nextcomma + 1]
                          else:
                              output += wrapL + argstr + wrapR + ','
                          first_occurrence = False
                      else:
                          output += source[currpos:currpos + nextcomma + 1]
                      currpos += nextcomma + 1
                  if numargs-1 in argnums:
                      if first_occurrence and notFirst:
                          # just include last argument as it was if this is
                          # the first occurrence
                          output += source[currpos:endbrace+1]
                      else:
                          # last argument needs to wrapped too
                          argstr = source[currpos:endbrace]
                          # get rid of leading or tailing whitespace
                          argstr = argstr.strip()
                          output += wrapL + argstr + wrapR + ')'
                      first_occurrence = False
                  else:
                      # just include last argument as it was
                      output += source[currpos:endbrace+1]
              else:
                  if argnums[0] != 0:
                      raise ValueError("Specified argument number out of range")
                  if first_occurrence and notFirst:
                      output += source[currpos:endbrace+1]
                  else:
                      argstr = source[currpos:endbrace]
                      # get rid of leading or tailing whitespace
                      argstr = argstr.strip()
                      output += wrapL + argstr + wrapR + ')'
                  first_occurrence = False
              currpos = endbrace+1
          else:
              output += source[currpos:]
      return output
code_tokens: def wrapArgInCall ( source , callfn , wrapL , wrapR = None , argnums = [ 0 ] , notFirst = False ) : done = False output = "" currpos = 0 first_occurrence = True if wrapR is None : wrapR = wrapL assert isinstance ( wrapL , str ) and isinstance ( wrapR , str ) , "Supplied delimiters must be strings" while not done : findposlist = [ source [ currpos : ] . find ( callfn + '(' ) ] try : findpos = min ( [ x for x in findposlist if x >= 0 ] ) + currpos except ValueError : done = True if not done : startbrace = source [ findpos : ] . find ( '(' ) + findpos endbrace = findEndBrace ( source [ startbrace : ] ) + startbrace output += source [ currpos : startbrace + 1 ] currpos = startbrace + 1 numargs = source [ startbrace + 1 : endbrace ] . count ( ',' ) + 1 if max ( argnums ) >= numargs : raise ValueError ( "Specified argument number out of range" ) if numargs > 1 : for argix in range ( numargs - 1 ) : nextcomma = source [ currpos : endbrace ] . find ( ',' ) argstr = source [ currpos : currpos + nextcomma ] argstr = argstr . strip ( ) if argix in argnums : if first_occurrence and notFirst : output += source [ currpos : currpos + nextcomma + 1 ] else : output += wrapL + argstr + wrapR + ',' first_occurrence = False else : output += source [ currpos : currpos + nextcomma + 1 ] currpos += nextcomma + 1 if numargs - 1 in argnums : if first_occurrence and notFirst : output += source [ currpos : endbrace + 1 ] else : argstr = source [ currpos : endbrace ] argstr = argstr . strip ( ) output += wrapL + argstr + wrapR + ')' first_occurrence = False else : output += source [ currpos : endbrace + 1 ] else : if argnums [ 0 ] != 0 : raise ValueError ( "Specified argument number out of range" ) if first_occurrence and notFirst : output += source [ currpos : endbrace + 1 ] else : argstr = source [ currpos : endbrace ] argstr = argstr . strip ( ) output += wrapL + argstr + wrapR + ')' first_occurrence = False currpos = endbrace + 1 else : output += source [ currpos : ] return output
short_docstring: Add delimiters to single argument in function call.
short_docstring_tokens: Add delimiters to single argument in function call .
comment: """Add delimiters to single argument in function call."""$SEP$# if no specific wrapR is specified, just use wrapL$SEP$# e.g. for symmetric delimiters such as quotes$SEP$# find callfn in source$SEP$# find start and end braces$SEP$# if more than one argument present, apply wrapping to specified$SEP$# arguments$SEP$# get rid of leading or tailing whitespace$SEP$# just include last argument as it was if this is$SEP$# the first occurrence$SEP$# last argument needs to wrapped too$SEP$# get rid of leading or tailing whitespace$SEP$# just include last argument as it was$SEP$# get rid of leading or tailing whitespace