Guido van Rossum | 31104f4 | 1992-01-14 18:28:36 +0000 | [diff] [blame] | 1 | # 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 Rossum | 1a76ef2 | 1992-03-31 18:57:28 +0000 | [diff] [blame] | 5 | # - os.path is either module posixpath or macpath |
Guido van Rossum | 31104f4 | 1992-01-14 18:28:36 +0000 | [diff] [blame] | 6 | # - os.name is either 'posix' or 'mac' |
| 7 | # - os.curdir is a string representing the current directory ('.' or ':') |
Guido van Rossum | 1a76ef2 | 1992-03-31 18:57:28 +0000 | [diff] [blame] | 8 | # - os.pardir is a string representing the parent directory ('..' or '::') |
Guido van Rossum | 31104f4 | 1992-01-14 18:28:36 +0000 | [diff] [blame] | 9 | |
| 10 | # Programs that import and use 'os' stand a better chance of being |
| 11 | # portable between different platforms. Of course, they must then |
| 12 | # only use functions that are defined by all platforms (e.g., unlink |
| 13 | # and opendir), and leave all pathname manipulation to os.path |
| 14 | # (e.g., split and join). |
| 15 | |
Guido van Rossum | 1a76ef2 | 1992-03-31 18:57:28 +0000 | [diff] [blame] | 16 | # XXX This will need to distinguish between real posix and MS-DOS emulation |
| 17 | |
Guido van Rossum | 31104f4 | 1992-01-14 18:28:36 +0000 | [diff] [blame] | 18 | try: |
| 19 | from posix import * |
| 20 | name = 'posix' |
| 21 | curdir = '.' |
Guido van Rossum | 1a76ef2 | 1992-03-31 18:57:28 +0000 | [diff] [blame] | 22 | pardir = '..' |
| 23 | import posixpath |
| 24 | path = posixpath |
| 25 | del posixpath |
Guido van Rossum | 31104f4 | 1992-01-14 18:28:36 +0000 | [diff] [blame] | 26 | except ImportError: |
| 27 | from mac import * |
| 28 | name = 'mac' |
| 29 | curdir = ':' |
Guido van Rossum | 1a76ef2 | 1992-03-31 18:57:28 +0000 | [diff] [blame] | 30 | pardir = '::' |
Guido van Rossum | 31104f4 | 1992-01-14 18:28:36 +0000 | [diff] [blame] | 31 | import macpath |
| 32 | path = macpath |
| 33 | del macpath |