def _on_raw(func_name):
 def wrapped(self, *args, **kwargs):
  args = list(args)
  try:
   string = args.pop(0)
   if hasattr(string, '_raw_string'):
    args.insert(0, string.raw())
   else:
    args.insert(0, string)
  except IndexError:
   pass
  result = getattr(self._raw_string, func_name)(*args, **kwargs)
  if isinstance(result, basestring):
   return ANSIString(result, decoded=True)
  return result
 return wrapped

def _on_raw ( func_name ) : def wrapped ( self , * args , ** kwargs ) : args = list ( args ) try : string = args . pop ( 0 ) if hasattr ( string , '_raw_string' ) : args . insert ( 0 , string . raw ( ) ) else : args . insert ( 0 , string ) except IndexError : pass result = getattr ( self . _raw_string , func_name ) ( * args , ** kwargs ) if isinstance ( result , basestring ) : return ANSIString ( result , decoded = True ) return result return wrapped
like query_super .