def addpackage(sitedir, name, known_paths):
 if (known_paths is None):
  _init_pathinfo()
  reset = 1
 else:
  reset = 0
 fullname = os.path.join(sitedir, name)
 try:
  f = open(fullname, 'rU')
 except IOError:
  return
 with f:
  for (n, line) in enumerate(f):
   if line.startswith('#'):
    continue
   try:
    if line.startswith(('import ', 'import DCTB ')):
     exec line
     continue
    line = line.rstrip()
    (dir, dircase) = makepath(sitedir, line)
    if ((not (dircase in known_paths)) and os.path.exists(dir)):
     sys.path.append(dir)
     known_paths.add(dircase)
   except Exception as err:
    print >>sys.stderr, 'Error processing line {:d} of {}:\n'.format((n + 1), fullname)
    for record in traceback.format_exception(*sys.exc_info()):
     for line in record.splitlines():
      print >>sys.stderr, ('  ' + line)
    print >>sys.stderr, '\nRemainder of file ignored'
    break
 if reset:
  known_paths = None
 return known_paths

def addpackage ( sitedir , name , known_paths ) : if ( known_paths is None ) : _init_pathinfo ( ) reset = 1 else : reset = 0 fullname = os . path . join ( sitedir , name ) try : f = open ( fullname , 'rU' ) except IOError : return with f : for ( n , line ) in enumerate ( f ) : if line . startswith ( '#' ) : continue try : if line . startswith ( ( 'import ' , 'import DCTB ' ) ) : exec line continue line = line . rstrip ( ) ( dir , dircase ) = makepath ( sitedir , line ) if ( ( not ( dircase in known_paths ) ) and os . path . exists ( dir ) ) : sys . path . append ( dir ) known_paths . add ( dircase ) except Exception as err : print >> sys . stderr , 'Error processing line {:d} of {}:\n' . format ( ( n + 1 ) , fullname ) for record in traceback . format_exception ( * sys . exc_info ( ) ) : for line in record . splitlines ( ) : print >> sys . stderr , ( '  ' + line ) print >> sys . stderr , '\nRemainder of file ignored' break if reset : known_paths = None return known_paths
process a .