(sitedir, name, known_paths)
return known_paths
Process a .pth file within the site-packages directory:
       For each line in the file, either combine it with sitedir to a path
       and add that to known_paths, or execute it if it starts with 'import '.
Process a .pth file within the site-packages directory:
       For each line in the file, either combine it with sitedir to a path
       and add that to known_paths, or execute it if it starts with 'import '.
Process a . pth file within the site - packages directory : For each line in the file either combine it with sitedir to a path and add that to known_paths or execute it if it starts with import .
def addpackage(sitedir, name, known_paths):
    """Process a .pth file within the site-packages directory:
       For each line in the file, either combine it with sitedir to a path
       and add that to known_paths, or execute it if it starts with 'import '.
    """
    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\t")):
                    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("Error processing line {:d} of {}:\n".format(n+1, fullname),
                      file=sys.stderr)
                for record in traceback.format_exception(*sys.exc_info()):
                    for line in record.splitlines():
                        print('  '+line, file=sys.stderr)
                print("\nRemainder of file ignored", file=sys.stderr)
                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\t" ) ) : 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 ( "Error processing line {:d} of {}:\n" . format ( n + 1 , fullname ) , file = sys . stderr ) for record in traceback . format_exception ( * sys . exc_info ( ) ) : for line in record . splitlines ( ) : print ( '  ' + line , file = sys . stderr ) print ( "\nRemainder of file ignored" , file = sys . stderr ) break if reset : known_paths = None return known_paths