blob: af0ce8956043d085745803df7f5f41c02725783a [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 *
21 name = 'posix'
22 curdir = '.'
Guido van Rossum1a76ef21992-03-31 18:57:28 +000023 pardir = '..'
Guido van Rossumb59cdd41992-04-06 14:03:45 +000024 sep = '/'
Guido van Rossum1a76ef21992-03-31 18:57:28 +000025 import posixpath
26 path = posixpath
27 del posixpath
Guido van Rossum31104f41992-01-14 18:28:36 +000028except ImportError:
29 from mac import *
30 name = 'mac'
31 curdir = ':'
Guido van Rossum1a76ef21992-03-31 18:57:28 +000032 pardir = '::'
Guido van Rossumb59cdd41992-04-06 14:03:45 +000033 sep = ':'
Guido van Rossum31104f41992-01-14 18:28:36 +000034 import macpath
35 path = macpath
36 del macpath