summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2003-02-14 19:35:31 (GMT)
committerSkip Montanaro <skip@pobox.com>2003-02-14 19:35:31 (GMT)
commit117910dc445a2262bd96bbfefaf43714ae59c11b (patch)
tree9dfb082f3e2975d50277035df0c3e8db70dbce7b /Lib
parent4507ec70cff35468f4b1767382f38ecebd4a29a2 (diff)
downloadcpython-117910dc445a2262bd96bbfefaf43714ae59c11b.zip
cpython-117910dc445a2262bd96bbfefaf43714ae59c11b.tar.gz
cpython-117910dc445a2262bd96bbfefaf43714ae59c11b.tar.bz2
Migrate definitions of several platform-dependent path-related variables
into the relevant path modules. See patch #686397.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/macpath.py10
-rw-r--r--Lib/ntpath.py16
-rw-r--r--Lib/os.py73
-rw-r--r--Lib/os2emxpath.py10
-rw-r--r--Lib/plat-riscos/riscospath.py8
-rw-r--r--Lib/posixpath.py10
6 files changed, 70 insertions, 57 deletions
diff --git a/Lib/macpath.py b/Lib/macpath.py
index e8ac467..8277d41 100644
--- a/Lib/macpath.py
+++ b/Lib/macpath.py
@@ -7,8 +7,18 @@ __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"basename","dirname","commonprefix","getsize","getmtime",
"getatime","getctime", "islink","exists","isdir","isfile",
"walk","expanduser","expandvars","normpath","abspath",
+ "curdir","pardir","sep","pathsep","defpath","altsep","extsep",
"realpath","supports_unicode_filenames"]
+# strings representing various path-related bits and pieces
+curdir = ':'
+pardir = '::'
+extsep = '.'
+sep = ':'
+pathsep = '\n'
+defpath = ':'
+altsep = None
+
# Normalize the case of a pathname. Dummy in Posix, but <s>.lower() here.
def normcase(path):
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index b820514..e39266b 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -13,8 +13,24 @@ __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"basename","dirname","commonprefix","getsize","getmtime",
"getatime","getctime", "islink","exists","isdir","isfile","ismount",
"walk","expanduser","expandvars","normpath","abspath","splitunc",
+ "curdir","pardir","sep","pathsep","defpath","altsep","extsep",
"realpath","supports_unicode_filenames"]
+# strings representing various path-related bits and pieces
+curdir = '.'
+pardir = '..'
+extsep = '.'
+sep = '\\'
+pathsep = ';'
+altsep = None
+if 'ce' in sys.builtin_module_names:
+ defpath = '\\Windows'
+elif 'os2' in sys.builtin_module_names:
+ # OS/2 w/ EMX
+ altsep = '/'
+else:
+ defpath = '.;C:\\bin'
+
# Normalize the case of a pathname and map slashes to backslashes.
# Other normalizations (such as optimizing '../' away) are not done
# (this is done by normpath).
diff --git a/Lib/os.py b/Lib/os.py
index e3b7761..d3078d6 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -26,10 +26,8 @@ import sys
_names = sys.builtin_module_names
-altsep = None
-
__all__ = ["altsep", "curdir", "pardir", "sep", "pathsep", "linesep",
- "defpath", "name"]
+ "defpath", "name", "path"]
def _get_exports_list(module):
try:
@@ -40,17 +38,13 @@ def _get_exports_list(module):
if 'posix' in _names:
name = 'posix'
linesep = '\n'
- curdir = '.'; pardir = '..'; sep = '/'; pathsep = ':'
- defpath = ':/bin:/usr/bin'
from posix import *
try:
from posix import _exit
except ImportError:
pass
- import posixpath
- path = posixpath
- del posixpath
-
+ import posixpath as path
+
import posix
__all__.extend(_get_exports_list(posix))
del posix
@@ -58,17 +52,13 @@ if 'posix' in _names:
elif 'nt' in _names:
name = 'nt'
linesep = '\r\n'
- curdir = '.'; pardir = '..'; sep = '\\'; pathsep = ';'
- defpath = '.;C:\\bin'
from nt import *
try:
from nt import _exit
except ImportError:
pass
- import ntpath
- path = ntpath
- del ntpath
-
+ import ntpath as path
+
import nt
__all__.extend(_get_exports_list(nt))
del nt
@@ -76,28 +66,16 @@ elif 'nt' in _names:
elif 'os2' in _names:
name = 'os2'
linesep = '\r\n'
- curdir = '.'; pardir = '..'; pathsep = ';'
- if sys.version.find('EMX GCC') == -1:
- # standard OS/2 compiler (VACPP or Watcom?)
- sep = '\\'; altsep = '/'
- else:
- # EMX
- sep = '/'; altsep = '\\'
- defpath = '.;C:\\bin'
from os2 import *
try:
from os2 import _exit
except ImportError:
pass
if sys.version.find('EMX GCC') == -1:
- import ntpath
- path = ntpath
- del ntpath
+ import ntpath as path
else:
- import os2emxpath
- path = os2emxpath
- del os2emxpath
-
+ import os2emxpath as path
+
import os2
__all__.extend(_get_exports_list(os2))
del os2
@@ -105,17 +83,13 @@ elif 'os2' in _names:
elif 'mac' in _names:
name = 'mac'
linesep = '\r'
- curdir = ':'; pardir = '::'; sep = ':'; pathsep = '\n'
- defpath = ':'
from mac import *
try:
from mac import _exit
except ImportError:
pass
- import macpath
- path = macpath
- del macpath
-
+ import macpath as path
+
import mac
__all__.extend(_get_exports_list(mac))
del mac
@@ -123,18 +97,14 @@ elif 'mac' in _names:
elif 'ce' in _names:
name = 'ce'
linesep = '\r\n'
- curdir = '.'; pardir = '..'; sep = '\\'; pathsep = ';'
- defpath = '\\Windows'
from ce import *
try:
from ce import _exit
except ImportError:
pass
# We can use the standard Windows path.
- import ntpath
- path = ntpath
- del ntpath
-
+ import ntpath as path
+
import ce
__all__.extend(_get_exports_list(ce))
del ce
@@ -142,17 +112,13 @@ elif 'ce' in _names:
elif 'riscos' in _names:
name = 'riscos'
linesep = '\n'
- curdir = '@'; pardir = '^'; sep = '.'; pathsep = ','
- defpath = '<Run$Dir>'
from riscos import *
try:
from riscos import _exit
except ImportError:
pass
- import riscospath
- path = riscospath
- del riscospath
-
+ import riscospath as path
+
import riscos
__all__.extend(_get_exports_list(riscos))
del riscos
@@ -160,18 +126,11 @@ elif 'riscos' in _names:
else:
raise ImportError, 'no os specific module found'
-
-if sep=='.':
- extsep = '/'
-else:
- extsep = '.'
-
-__all__.append("path")
+sys.modules['os.path'] = path
+from os.path import curdir, pardir, sep, pathsep, defpath, extsep, altsep
del _names
-sys.modules['os.path'] = path
-
#'
# Super directory utilities.
diff --git a/Lib/os2emxpath.py b/Lib/os2emxpath.py
index f92841f..67f00df 100644
--- a/Lib/os2emxpath.py
+++ b/Lib/os2emxpath.py
@@ -12,8 +12,18 @@ __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"basename","dirname","commonprefix","getsize","getmtime",
"getatime","getctime", "islink","exists","isdir","isfile","ismount",
"walk","expanduser","expandvars","normpath","abspath","splitunc",
+ "curdir","pardir","sep","pathsep","defpath","altsep","extsep",
"realpath","supports_unicode_filenames"]
+# strings representing various path-related bits and pieces
+curdir = '.'
+pardir = '..'
+extsep = '.'
+sep = '/'
+altsep = '\\'
+pathsep = ';'
+defpath = '.;C:\\bin'
+
# Normalize the case of a pathname and map slashes to backslashes.
# Other normalizations (such as optimizing '../' away) are not done
# (this is done by normpath).
diff --git a/Lib/plat-riscos/riscospath.py b/Lib/plat-riscos/riscospath.py
index 30c0c9f..c875a4f 100644
--- a/Lib/plat-riscos/riscospath.py
+++ b/Lib/plat-riscos/riscospath.py
@@ -12,6 +12,14 @@ Instead of importing this module directly, import os and refer to this module
as os.path.
"""
+# strings representing various path-related bits and pieces
+curdir = '@'
+pardir = '^'
+extsep = '.'
+sep = '.'
+pathsep = ','
+defpath = '<Run$Dir>'
+altsep = None
# Imports - make an error-generating swi object if the swi module is not
# available (ie. we are not running on RISC OS Python)
diff --git a/Lib/posixpath.py b/Lib/posixpath.py
index d0179f1..50073dc 100644
--- a/Lib/posixpath.py
+++ b/Lib/posixpath.py
@@ -18,8 +18,18 @@ __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"getatime","getctime","islink","exists","isdir","isfile","ismount",
"walk","expanduser","expandvars","normpath","abspath",
"samefile","sameopenfile","samestat",
+ "curdir","pardir","sep","pathsep","defpath","altsep","extsep",
"realpath","supports_unicode_filenames"]
+# strings representing various path-related bits and pieces
+curdir = '.'
+pardir = '..'
+extsep = '.'
+sep = '/'
+pathsep = ':'
+defpath = ':/bin:/usr/bin'
+altsep = None
+
# Normalize the case of a pathname. Trivial in Posix, string.lower on Mac.
# On MS-DOS this may also turn slashes into backslashes; however, other
# normalizations (such as optimizing '../' away) are not allowed