@decorator
def sudo_support(fn, command):
 if (not command.script.startswith('sudo ')):
  return fn(command)
 result = fn(command.update(script=command.script[5:]))
 if (result and isinstance(result, six.string_types)):
  return u'sudo {}'.format(result)
 elif isinstance(result, list):
  return [u'sudo {}'.format(x) for x in result]
 else:
  return result

@ decorator def sudo_support ( fn , command ) : if ( not command . script . startswith ( 'sudo ' ) ) : return fn ( command ) result = fn ( command . update ( script = command . script [ 5 : ] ) ) if ( result and isinstance ( result , six . string_types ) ) : return u'sudo {}' . format ( result ) elif isinstance ( result , list ) : return [ u'sudo {}' . format ( x ) for x in result ] else : return result
removes sudo before calling fn and adds it after .