# Path: nord/utils.py
# def setv(g2param, val):
#   '''setv(g2param, val) - set all variations to val.'''
#   g2param.variations = [ val ] * 9
# 
# def getv(nmparam, variation=0):
#   '''getv(nmparam) - get variations[variation].'''
#   return nmparam.variations[variation]
# 
# Path: nord/g2/colors.py

# 
# Path: nord/nm1/colors.py

# 
# Path: nord/units.py
# def nm2g2val(nm1midival, nm1vals, g2vals):
#   nm1val = nm1vals[nm1midival]
#   g2min = 1000000 # nothing here will never be that big
#   g2midival = 0
#   for midival in xrange(128):
#     g2val = g2vals[midival]
#     if abs(g2val-nm1val) < g2min:
#       g2min = abs(g2val-nm1val)
#       g2midival = midival
#   return g2midival
# 
# Path: nord/utils.py
# def toascii(s):
#   # conversion strings for 192-255
#   s161 = '!cL#Y|S"Ca<^-R-o+23\'uP.10>%%%?' \
#          'AAAAAAACEEEEIIIIDNOOOOOOXOUUUUYpBaaaaaaaceeeeeiiiienooooo/ouuuuypy'
#   def conv(c):
#     o = ord(c)
#     if o < 128:
#       return c
#     elif o < 161:
#       return chr(c-64)
#     else:
#       return s161[o-161]
#     return ''
#   return ''.join([ conv(c) for c in s ])
# 
# Path: nord/convert/table.py



from nord.utils import setv, getv
from nord.g2.colors import g2cablecolors
from nord.nm1.colors import nm1conncolors
from nord.units import nm2g2val
from nord.utils import toascii
from nord.convert.table import kbttable
    '''emptyspace(column, rowstart, rowend) -> True or False
    return True of no modules in column from rowstart to rowend.
    '''
    pass
    
  def insertcolumn(self, column):
    '''insertcolumn(column) -> None
    readjust horiz>=column for all modules in both g2area, nmarea
    '''
    for module in self.nmarea.modules:
      if module.horiz >= column:
        module.horiz += 1

    for module in self.g2area.modules:
      if module.horiz >= column:
        module.horiz += 1

def handlekbt(conv, input, kbt100, addalways=False):
  '''handlekbt(conv, input, kbt100, addalways=False) -> input
  '''
  nmm, g2m = conv.nmmodule, conv.g2module
  nmmp, g2mp = nmm.params, g2m.params

  kbt = getv(nmmp.Kbt)
  if addalways:
    pass
  elif kbt == 0:
    setv(conv.kbt, kbt)
    return None
  elif kbt == 64:

# Path: nord/utils.py
# def setv(g2param, val):
#   '''setv(g2param, val) - set all variations to val.'''
#   g2param.variations = [ val ] * 9
# 
# def getv(nmparam, variation=0):
#   '''getv(nmparam) - get variations[variation].'''
#   return nmparam.variations[variation]
# 
# Path: nord/g2/colors.py

# 
# Path: nord/nm1/colors.py

# 
# Path: nord/units.py
# def nm2g2val(nm1midival, nm1vals, g2vals):
#   nm1val = nm1vals[nm1midival]
#   g2min = 1000000 # nothing here will never be that big
#   g2midival = 0
#   for midival in xrange(128):
#     g2val = g2vals[midival]
#     if abs(g2val-nm1val) < g2min:
#       g2min = abs(g2val-nm1val)
#       g2midival = midival
#   return g2midival
# 
# Path: nord/utils.py
# def toascii(s):
#   # conversion strings for 192-255
#   s161 = '!cL#Y|S"Ca<^-R-o+23\'uP.10>%%%?' \
#          'AAAAAAACEEEEIIIIDNOOOOOOXOUUUUYpBaaaaaaaceeeeeiiiienooooo/ouuuuypy'
#   def conv(c):
#     o = ord(c)
#     if o < 128:
#       return c
#     elif o < 161:
#       return chr(c-64)
#     else:
#       return s161[o-161]
#     return ''
#   return ''.join([ conv(c) for c in s ])
# 
# Path: nord/convert/table.py



# Path: nord/convert/convert.py
from nord.utils import setv, getv
from nord.g2.colors import g2cablecolors
from nord.nm1.colors import nm1conncolors
from nord.units import nm2g2val
from nord.utils import toascii
from nord.convert.table import kbttable

    '''emptyspace(column, rowstart, rowend) -> True or False
    return True of no modules in column from rowstart to rowend.
    '''
    pass
    
  def insertcolumn(self, column):
    '''insertcolumn(column) -> None
    readjust horiz>=column for all modules in both g2area, nmarea
    '''
    for module in self.nmarea.modules:
      if module.horiz >= column:
        module.horiz += 1

    for module in self.g2area.modules:
      if module.horiz >= column:
        module.horiz += 1

def handlekbt(conv, input, kbt100, addalways=False):
  '''handlekbt(conv, input, kbt100, addalways=False) -> input
  '''
  nmm, g2m = conv.nmmodule, conv.g2module
  nmmp, g2mp = nmm.params, g2m.params

  kbt = getv(nmmp.Kbt)
  if addalways:
    pass
  elif kbt == 0:
    setv(conv.kbt, kbt)
    return None
  elif kbt == 64:

    setv(conv.kbt, kbt100)