def parse_gid(gid):
 try:
  return int(gid)
 except ValueError:
  try:
   return grp.getgrnam(gid).gr_gid
  except (AttributeError, KeyError):
   raise KeyError(u'Group does not exist: {0}'.format(gid))

def parse_gid ( gid ) : try : return int ( gid ) except ValueError : try : return grp . getgrnam ( gid ) . gr_gid except ( AttributeError , KeyError ) : raise KeyError ( u'Group does not exist: {0}' . format ( gid ) )
parse group id .