# Path: wh.py
# def xlt(s): # translate
#   return s
#   t=wx.GetTranslation(s)
#   # if dict set and t == s: log untranslated
#   return t
# 
# def modPath(name, mod):
#   """
#   str modPath(filename, module)
#   
#   prepend module's path to filename
#   """
#   if mod:
#     if not isinstance(mod, StringType):
#       mod=mod.__module__
#     ri=mod.rfind('.')
#     if ri > 0:
#       return os.path.join(loaddir, mod[0:ri].replace('.', '/'), name)
# 
#   return os.path.join(loaddir, name)


import psycopg2
import select
import logger
import adm
import re
import threading
from wh import xlt, modPath
from Crypto.PublicKey._slowmath import rsa_construct
class pgTypeCache:
  def __init__(self, rowset):
    self.cache={}
    self.Add(rowset)
  
  def Add(self, rowset):
    if not isinstance(rowset, pgRowset):
      rowset=[rowset]
    typ=None
    for row in rowset:
      typ=pgType(row)
      self.cache[typ.oid] = typ
    return typ
    
  def Get(self, oid):
    return self.cache.get(oid)
  
  
######################################################################
class pgCursorResult:
  def __init__(self, cursor, colNames=None):
    self.cursor=cursor
    if colNames:
      self.colNames=colNames
    else:
      self.colNames=[]
      for d in cursor.GetDescription():
        self.colNames.append(d.name)
      
      

# Path: wh.py
# def xlt(s): # translate
#   return s
#   t=wx.GetTranslation(s)
#   # if dict set and t == s: log untranslated
#   return t
# 
# def modPath(name, mod):
#   """
#   str modPath(filename, module)
#   
#   prepend module's path to filename
#   """
#   if mod:
#     if not isinstance(mod, StringType):
#       mod=mod.__module__
#     ri=mod.rfind('.')
#     if ri > 0:
#       return os.path.join(loaddir, mod[0:ri].replace('.', '/'), name)
# 
#   return os.path.join(loaddir, name)


# Path: modPg/_pgsql.py
import psycopg2
import select
import logger
import adm
import re
import threading
from wh import xlt, modPath
from Crypto.PublicKey._slowmath import rsa_construct

class pgTypeCache:
  def __init__(self, rowset):
    self.cache={}
    self.Add(rowset)
  
  def Add(self, rowset):
    if not isinstance(rowset, pgRowset):
      rowset=[rowset]
    typ=None
    for row in rowset:
      typ=pgType(row)
      self.cache[typ.oid] = typ
    return typ
    
  def Get(self, oid):
    return self.cache.get(oid)
  
  
######################################################################
class pgCursorResult:
  def __init__(self, cursor, colNames=None):
    self.cursor=cursor
    if colNames:
      self.colNames=colNames
    else:
      self.colNames=[]
      for d in cursor.GetDescription():
        self.colNames.append(d.name)
      
      

class pgRow(pgCursorResult):