[Zope-Checkins] CVS: Zope/lib/python/App - Common.py:1.18
Fred L. Drake, Jr.
fred@zope.com
Thu, 30 Jan 2003 14:06:38 -0500
Update of /cvs-repository/Zope/lib/python/App
In directory cvs.zope.org:/tmp/cvs-serv13904
Modified Files:
Common.py
Log Message:
We can simplify the definition of realpath() since we require Python
2.2 now.
=== Zope/lib/python/App/Common.py 1.17 => 1.18 ===
--- Zope/lib/python/App/Common.py:1.17 Fri Nov 15 14:21:56 2002
+++ Zope/lib/python/App/Common.py Thu Jan 30 14:06:36 2003
@@ -17,6 +17,9 @@
import sys, os, time
+# Legacy API for this module; 3rd party code may use this.
+from os.path import realpath
+
# These are needed because the various date formats below must
# be in english per the RFCs. That means we can't use strftime,
@@ -128,32 +131,3 @@
return default
def Dictionary(**kw): return kw # Sorry Guido
-
-try:
- # Python 2.2. already has a realpath function, while 2.1 doesn't
- realpath = os.path.realpath
-except:
- if os.name == 'posix':
- def realpath(filename):
- """
- Return the canonical path of the specified filename,
- eliminating any symbolic links encountered in the path
- (this is ripped off from Python 2.2).
- """
- filename = os.path.abspath(filename)
-
- bits = ['/'] + filename.split('/')[1:]
- for i in range(2, len(bits)+1):
- component = os.path.join(*bits[0:i])
- if os.path.islink(component):
- resolved = os.readlink(component)
- (dir, file) = os.path.split(component)
- resolved = os.path.normpath(os.path.join(dir, resolved))
- newpath = os.path.join(*([resolved] + bits[i:]))
- return realpath(newpath)
-
- return filename
- else:
- # other platforms are assumed to not have symlinks, so we alias
- # realpath to abspath
- realpath = os.path.abspath