# Path: wh.py
# def xlt(s): # translate
#   return s
#   t=wx.GetTranslation(s)
#   # if dict set and t == s: log untranslated
#   return t
# 
# def YesNo(b):
#   if b:
#     return xlt("Yes")
#   else:
#     return xlt("No")
# 
# def prettyDate(val, long=True):
#   if isinstance(val, datetime.datetime):
#     val=val.timetuple()
#   if not isinstance(val, time.struct_time):
#     val=time.localtime(val)
#   if long:
#     return time.strftime("%Y-%m-%d %H:%M:%S", val)
#   else:
#     return time.strftime("%Y-%m-%d", val)


import adm
from wh import xlt, YesNo, prettyDate
    if node != self.lastNode:
      self.lastNode=node

      def members(row):
        d=row['members']
        if d:  return ",".join(d)
      def flags(row):
        fl=[]
        for key, desc in self.roleFlags.items():
          if row.get(key):
            fl.append(desc)
        return" ".join(fl)
        
      add=self.control.AddColumnInfo
      add(xlt("Name"), 20,         colname='name')
      add(xlt("Flags"), 25,        proc=flags)
      add(xlt("Members"), 40,      proc=members)

      values=[]
      
      self.allRoles=node.GetConnection().GetCursor().ExecuteDictList("""
        SELECT rolname as name, *,
          (SELECT array_agg(rolname) FROM pg_roles r JOIN pg_auth_members m on r.oid=m.member WHERE m.roleid=u.oid) AS members,
          (SELECT array_agg(rolname) FROM pg_roles r JOIN pg_auth_members m on r.oid=m.roleid WHERE m.member=u.oid) AS memberof
          FROM pg_roles u ORDER BY rolname""")
      
      for role in self.allRoles:
        # rolsuper, rolcreaterole, colcreatedb, rolcanupdate
        icons=[]
        if role['members']:

# Path: wh.py
# def xlt(s): # translate
#   return s
#   t=wx.GetTranslation(s)
#   # if dict set and t == s: log untranslated
#   return t
# 
# def YesNo(b):
#   if b:
#     return xlt("Yes")
#   else:
#     return xlt("No")
# 
# def prettyDate(val, long=True):
#   if isinstance(val, datetime.datetime):
#     val=val.timetuple()
#   if not isinstance(val, time.struct_time):
#     val=time.localtime(val)
#   if long:
#     return time.strftime("%Y-%m-%d %H:%M:%S", val)
#   else:
#     return time.strftime("%Y-%m-%d", val)


# Path: modPg/Role.py
import adm
from wh import xlt, YesNo, prettyDate

    if node != self.lastNode:
      self.lastNode=node

      def members(row):
        d=row['members']
        if d:  return ",".join(d)
      def flags(row):
        fl=[]
        for key, desc in self.roleFlags.items():
          if row.get(key):
            fl.append(desc)
        return" ".join(fl)
        
      add=self.control.AddColumnInfo
      add(xlt("Name"), 20,         colname='name')
      add(xlt("Flags"), 25,        proc=flags)
      add(xlt("Members"), 40,      proc=members)

      values=[]
      
      self.allRoles=node.GetConnection().GetCursor().ExecuteDictList("""
        SELECT rolname as name, *,
          (SELECT array_agg(rolname) FROM pg_roles r JOIN pg_auth_members m on r.oid=m.member WHERE m.roleid=u.oid) AS members,
          (SELECT array_agg(rolname) FROM pg_roles r JOIN pg_auth_members m on r.oid=m.roleid WHERE m.member=u.oid) AS memberof
          FROM pg_roles u ORDER BY rolname""")
      
      for role in self.allRoles:
        # rolsuper, rolcreaterole, colcreatedb, rolcanupdate
        icons=[]
        if role['members']:

          icons.append("group")