[ZPT] CVS: Packages/TAL - .cvsignore:1.1 setpath.py:1.3

guido@digicool.com guido@digicool.com
Tue, 27 Mar 2001 11:19:10 -0500 (EST)


Update of /cvs-repository/Packages/TAL
In directory korak:/tmp/cvs-serv8787

Modified Files:
	setpath.py 
Added Files:
	.cvsignore 
Log Message:
Evan checked in *his* version of setpath.py, which broke for me.

To prevent this in the future, read the path from a file .path.




--- Added File .cvsignore in package Packages/TAL ---
.path

--- Updated File setpath.py in package Packages/TAL --
--- setpath.py	2001/03/27 11:46:01	1.2
+++ setpath.py	2001/03/27 16:19:09	1.3
@@ -1,14 +1,23 @@
 """
-Edit this file to set the proper module search path.
+Read a module search path from .path.
 """
 import os
 import sys
+import string
 
-home = os.path.expanduser("~")
-Zopes = os.path.join(home, 'Zope')
-pt = os.path.join(Zopes, 'pt')
-libPython = os.path.join(pt, 'lib', 'python')
-
-sys.path.append(libPython)
+dir = os.path.dirname(__file__)
+path = os.path.join(dir, ".path")
+try:
+    f = open(path)
+except IOError:
+    raise IOError, "Please edit .path to point to <Zope2/lib/python>"
+else:
+    for line in f.readlines():
+        line = string.strip(line)
+        if line and line[0] != '#':
+            for dir in string.split(line, os.pathsep):
+                dir = os.path.expanduser(os.path.expandvars(dir))
+                if dir not in sys.path:
+                    sys.path.append(dir)
 
 import ZODB # Must import this first to initialize Persistence properly