def _update_gecos(name, key, value):
 if (not isinstance(value, six.string_types)):
  value = str(value)
 pre_info = _get_gecos(name)
 if (not pre_info):
  return False
 if (value == pre_info[key]):
  return True
 gecos_data = copy.deepcopy(pre_info)
 gecos_data[key] = value
 cmd = ['pw', 'usermod', name, '-c', _build_gecos(gecos_data)]
 __salt__['cmd.run'](cmd, python_shell=False)
 post_info = info(name)
 return (_get_gecos(name).get(key) == value)

def _update_gecos ( name , key , value ) : if ( not isinstance ( value , six . string_types ) ) : value = str ( value ) pre_info = _get_gecos ( name ) if ( not pre_info ) : return False if ( value == pre_info [ key ] ) : return True gecos_data = copy . deepcopy ( pre_info ) gecos_data [ key ] = value cmd = [ 'pw' , 'usermod' , name , '-c' , _build_gecos ( gecos_data ) ] __salt__ [ 'cmd.run' ] ( cmd , python_shell = False ) post_info = info ( name ) return ( _get_gecos ( name ) . get ( key ) == value )
common code to change a users gecos information .