def patchUserDatabase(patch, user, uid, group, gid):
 pwent = pwd.getpwuid(os.getuid())
 grent = grp.getgrgid(os.getgid())
 database = UserDatabase()
 database.addUser(user, pwent.pw_passwd, uid, pwent.pw_gid, pwent.pw_gecos, pwent.pw_dir, pwent.pw_shell)
 def getgrnam(name):
  result = list(grent)
  result[result.index(grent.gr_name)] = group
  result[result.index(grent.gr_gid)] = gid
  result = tuple(result)
  return {group: result}[name]
 patch(pwd, 'getpwnam', database.getpwnam)
 patch(grp, 'getgrnam', getgrnam)

def patchUserDatabase ( patch , user , uid , group , gid ) : pwent = pwd . getpwuid ( os . getuid ( ) ) grent = grp . getgrgid ( os . getgid ( ) ) database = UserDatabase ( ) database . addUser ( user , pwent . pw_passwd , uid , pwent . pw_gid , pwent . pw_gecos , pwent . pw_dir , pwent . pw_shell ) def getgrnam ( name ) : result = list ( grent ) result [ result . index ( grent . gr_name ) ] = group result [ result . index ( grent . gr_gid ) ] = gid result = tuple ( result ) return { group : result } [ name ] patch ( pwd , 'getpwnam' , database . getpwnam ) patch ( grp , 'getgrnam' , getgrnam )
patch l{pwd .