# 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
    
  def GetIcon(self):
    icons=[]
    if self.info['members']:
      icons.append("Group")
    else:
      icons.append("User")
    return self.GetImageId(icons)
  
  
  def GetProperties(self):
    if not len(self.properties):

      self.properties = [
        (xlt("Name"), self.name, self.GetImageId('Role')),
        (    "OID",   self.info['oid']),
        (xlt("Can Login"), YesNo(self.info['rolcanlogin'])),
        (xlt("Superuser"), YesNo(self.info['rolsuper'])),
        (xlt("Catalog Update"), YesNo(self.info['rolcatupdate'])),
        (xlt("Create DB"), YesNo(self.info['rolcreatedb'])),
        (xlt("Create Role"), YesNo(self.info['rolcreaterole'])),
        (xlt("Inherits rights"), YesNo(self.info['rolinherit'])),
      ]
      until=self.info['rolvaliduntil']
      if not until or until.year == 9999:
        until=xlt("never")
      else:
        until=prettyDate(until)
      self.properties.append((xlt("Expires"), until))
      

# 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

    
  def GetIcon(self):
    icons=[]
    if self.info['members']:
      icons.append("Group")
    else:
      icons.append("User")
    return self.GetImageId(icons)
  
  
  def GetProperties(self):
    if not len(self.properties):

      self.properties = [
        (xlt("Name"), self.name, self.GetImageId('Role')),
        (    "OID",   self.info['oid']),
        (xlt("Can Login"), YesNo(self.info['rolcanlogin'])),
        (xlt("Superuser"), YesNo(self.info['rolsuper'])),
        (xlt("Catalog Update"), YesNo(self.info['rolcatupdate'])),
        (xlt("Create DB"), YesNo(self.info['rolcreatedb'])),
        (xlt("Create Role"), YesNo(self.info['rolcreaterole'])),
        (xlt("Inherits rights"), YesNo(self.info['rolinherit'])),
      ]
      until=self.info['rolvaliduntil']
      if not until or until.year == 9999:
        until=xlt("never")
      else:
        until=prettyDate(until)
      self.properties.append((xlt("Expires"), until))
      

      self.AddChildrenProperty(self.info['memberof'], xlt("Member of"), self.GetImageId("Group"))