blob: 556268fe4e89a7f14be1494f5fc594f8e35150ff [file] [log] [blame]
Guido van Rossum31104f41992-01-14 18:28:36 +00001# os.py -- either mac or posix depending on what system we're on.
2
3# This exports:
4# - all functions from either posix or mac, e.g., os.unlink, os.stat, etc.
Guido van Rossum1a76ef21992-03-31 18:57:28 +00005# - os.path is either module posixpath or macpath
Guido van Rossum31104f41992-01-14 18:28:36 +00006# - os.name is either 'posix' or 'mac'
7# - os.curdir is a string representing the current directory ('.' or ':')
Guido van Rossum1a76ef21992-03-31 18:57:28 +00008# - os.pardir is a string representing the parent directory ('..' or '::')
Guido van Rossumb59cdd41992-04-06 14:03:45 +00009# - os.sep is the (or a most common) pathname separator ('/' or ':')
Guido van Rossum31104f41992-01-14 18:28:36 +000010
11# Programs that import and use 'os' stand a better chance of being
12# portable between different platforms. Of course, they must then
13# only use functions that are defined by all platforms (e.g., unlink
14# and opendir), and leave all pathname manipulation to os.path
15# (e.g., split and join).
16
Guido van Rossum1a76ef21992-03-31 18:57:28 +000017# XXX This will need to distinguish between real posix and MS-DOS emulation
18
Guido van Rossum31104f41992-01-14 18:28:36 +000019try:
20 from posix import *
Guido van Rossum7a461e51992-09-20 21:41:09 +000021 from posix import _exit
Guido van Rossum31104f41992-01-14 18:28:36 +000022 name = 'posix'
23 curdir = '.'
Guido van Rossum1a76ef21992-03-31 18:57:28 +000024 pardir = '..'
Guido van Rossumb59cdd41992-04-06 14:03:45 +000025 sep = '/'
Guido van Rossum1a76ef21992-03-31 18:57:28 +000026 import posixpath
27 path = posixpath
28 del posixpath
Guido van Rossum31104f41992-01-14 18:28:36 +000029except ImportError:
30 from mac import *
31 name = 'mac'
32 curdir = ':'
Guido van Rossum1a76ef21992-03-31 18:57:28 +000033 pardir = '::'
Guido van Rossumb59cdd41992-04-06 14:03:45 +000034 sep = ':'
Guido van Rossum31104f41992-01-14 18:28:36 +000035 import macpath
36 path = macpath
37 del macpath