mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
RISCOS changes by dschwertberger.
This commit is contained in:
parent
4ba3d657ef
commit
d74fb6b12a
6 changed files with 64 additions and 24 deletions
|
@ -33,9 +33,13 @@ error = IOError # For anydbm
|
||||||
class _Database:
|
class _Database:
|
||||||
|
|
||||||
def __init__(self, file):
|
def __init__(self, file):
|
||||||
self._dirfile = file + '.dir'
|
if _os.sep == '.':
|
||||||
self._datfile = file + '.dat'
|
endsep = '/'
|
||||||
self._bakfile = file + '.bak'
|
else:
|
||||||
|
endsep = '.'
|
||||||
|
self._dirfile = file + endsep + 'dir'
|
||||||
|
self._datfile = file + endsep + 'dat'
|
||||||
|
self._bakfile = file + endsep + 'bak'
|
||||||
# Mod by Jack: create data file if needed
|
# Mod by Jack: create data file if needed
|
||||||
try:
|
try:
|
||||||
f = _open(self._datfile, 'r')
|
f = _open(self._datfile, 'r')
|
||||||
|
|
50
Lib/os.py
50
Lib/os.py
|
@ -3,7 +3,7 @@
|
||||||
This exports:
|
This exports:
|
||||||
- all functions from posix, nt, dos, os2, mac, or ce, e.g. unlink, stat, etc.
|
- all functions from posix, nt, dos, os2, mac, or ce, e.g. unlink, stat, etc.
|
||||||
- os.path is one of the modules posixpath, ntpath, macpath, or dospath
|
- os.path is one of the modules posixpath, ntpath, macpath, or dospath
|
||||||
- os.name is 'posix', 'nt', 'dos', 'os2', 'mac', or 'ce'
|
- os.name is 'posix', 'nt', 'dos', 'os2', 'mac', 'ce' or 'riscos'
|
||||||
- os.curdir is a string representing the current directory ('.' or ':')
|
- os.curdir is a string representing the current directory ('.' or ':')
|
||||||
- os.pardir is a string representing the parent directory ('..' or '::')
|
- os.pardir is a string representing the parent directory ('..' or '::')
|
||||||
- os.sep is the (or a most common) pathname separator ('/' or ':' or '\\')
|
- os.sep is the (or a most common) pathname separator ('/' or ':' or '\\')
|
||||||
|
@ -147,6 +147,25 @@ elif 'ce' in _names:
|
||||||
__all__.extend(_get_exports_list(ce))
|
__all__.extend(_get_exports_list(ce))
|
||||||
del ce
|
del ce
|
||||||
|
|
||||||
|
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
|
||||||
|
from riscosenviron import environ
|
||||||
|
|
||||||
|
import riscos
|
||||||
|
__all__.extend(_get_exports_list(riscos))
|
||||||
|
del ce
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise ImportError, 'no os specific module found'
|
raise ImportError, 'no os specific module found'
|
||||||
|
|
||||||
|
@ -317,14 +336,16 @@ def _execvpe(file, args, env=None):
|
||||||
exc, arg = error, (errno, msg)
|
exc, arg = error, (errno, msg)
|
||||||
raise exc, arg
|
raise exc, arg
|
||||||
|
|
||||||
# Change environ to automatically call putenv() if it exists
|
|
||||||
try:
|
if name != "riscos":
|
||||||
# This will fail if there's no putenv
|
# Change environ to automatically call putenv() if it exists
|
||||||
putenv
|
try:
|
||||||
except NameError:
|
# This will fail if there's no putenv
|
||||||
pass
|
putenv
|
||||||
else:
|
except NameError:
|
||||||
import UserDict
|
pass
|
||||||
|
else:
|
||||||
|
import UserDict
|
||||||
|
|
||||||
if name in ('os2', 'nt', 'dos'): # Where Env Var Names Must Be UPPERCASE
|
if name in ('os2', 'nt', 'dos'): # Where Env Var Names Must Be UPPERCASE
|
||||||
# But we store them as upper case
|
# But we store them as upper case
|
||||||
|
@ -363,12 +384,11 @@ else:
|
||||||
|
|
||||||
environ = _Environ(environ)
|
environ = _Environ(environ)
|
||||||
|
|
||||||
def getenv(key, default=None):
|
def getenv(key, default=None):
|
||||||
"""Get an environment variable, return None if it doesn't exist.
|
"""Get an environment variable, return None if it doesn't exist.
|
||||||
|
The optional second argument can specify an alternate default."""
|
||||||
The optional second argument can specify an alternate default."""
|
return environ.get(key, default)
|
||||||
return environ.get(key, default)
|
__all__.append("getenv")
|
||||||
__all__.append("getenv")
|
|
||||||
|
|
||||||
def _exists(name):
|
def _exists(name):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -59,6 +59,12 @@ ImportError exception, it is silently ignored.
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
|
if os.sep==".":
|
||||||
|
endsep = "/"
|
||||||
|
else:
|
||||||
|
endsep = "."
|
||||||
|
|
||||||
|
|
||||||
def makepath(*paths):
|
def makepath(*paths):
|
||||||
dir = os.path.join(*paths)
|
dir = os.path.join(*paths)
|
||||||
return os.path.normcase(os.path.abspath(dir))
|
return os.path.normcase(os.path.abspath(dir))
|
||||||
|
@ -99,7 +105,7 @@ def addsitedir(sitedir):
|
||||||
names = map(os.path.normcase, names)
|
names = map(os.path.normcase, names)
|
||||||
names.sort()
|
names.sort()
|
||||||
for name in names:
|
for name in names:
|
||||||
if name[-4:] == ".pth":
|
if name[-4:] == endsep + "pth":
|
||||||
addpackage(sitedir, name)
|
addpackage(sitedir, name)
|
||||||
|
|
||||||
def addpackage(sitedir, name):
|
def addpackage(sitedir, name):
|
||||||
|
|
|
@ -48,7 +48,8 @@ __all__.extend(os._get_exports_list(_socket))
|
||||||
del _socket
|
del _socket
|
||||||
|
|
||||||
if (sys.platform.lower().startswith("win")
|
if (sys.platform.lower().startswith("win")
|
||||||
or (hasattr(os, 'uname') and os.uname()[0] == "BeOS")):
|
or (hasattr(os, 'uname') and os.uname()[0] == "BeOS")
|
||||||
|
or (sys.platform=="RISCOS")):
|
||||||
|
|
||||||
# be sure this happens only once, even in the face of reload():
|
# be sure this happens only once, even in the face of reload():
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -41,6 +41,8 @@ if os.name == 'mac':
|
||||||
from macurl2path import url2pathname, pathname2url
|
from macurl2path import url2pathname, pathname2url
|
||||||
elif os.name == 'nt':
|
elif os.name == 'nt':
|
||||||
from nturl2path import url2pathname, pathname2url
|
from nturl2path import url2pathname, pathname2url
|
||||||
|
elif os.name == 'riscos':
|
||||||
|
from rourl2path import url2pathname, pathname2url
|
||||||
else:
|
else:
|
||||||
def url2pathname(pathname):
|
def url2pathname(pathname):
|
||||||
return unquote(pathname)
|
return unquote(pathname)
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
"""Guess which db package to use to open a db file."""
|
"""Guess which db package to use to open a db file."""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
if os.sep==".":
|
||||||
|
endsep = "/"
|
||||||
|
else:
|
||||||
|
endsep = "."
|
||||||
|
|
||||||
def whichdb(filename):
|
def whichdb(filename):
|
||||||
"""Guess which db package to use to open a db file.
|
"""Guess which db package to use to open a db file.
|
||||||
|
|
||||||
|
@ -17,9 +24,9 @@ def whichdb(filename):
|
||||||
|
|
||||||
# Check for dbm first -- this has a .pag and a .dir file
|
# Check for dbm first -- this has a .pag and a .dir file
|
||||||
try:
|
try:
|
||||||
f = open(filename + ".pag", "rb")
|
f = open(filename + endsep + "pag", "rb")
|
||||||
f.close()
|
f.close()
|
||||||
f = open(filename + ".dir", "rb")
|
f = open(filename + endsep + "dir", "rb")
|
||||||
f.close()
|
f.close()
|
||||||
return "dbm"
|
return "dbm"
|
||||||
except IOError:
|
except IOError:
|
||||||
|
@ -27,9 +34,9 @@ def whichdb(filename):
|
||||||
|
|
||||||
# Check for dumbdbm next -- this has a .dir and and a .dat file
|
# Check for dumbdbm next -- this has a .dir and and a .dat file
|
||||||
try:
|
try:
|
||||||
f = open(filename + ".dat", "rb")
|
f = open(filename + endsep + "dat", "rb")
|
||||||
f.close()
|
f.close()
|
||||||
f = open(filename + ".dir", "rb")
|
f = open(filename + endsep + "dir", "rb")
|
||||||
try:
|
try:
|
||||||
if f.read(1) in ["'", '"']:
|
if f.read(1) in ["'", '"']:
|
||||||
return "dumbdbm"
|
return "dumbdbm"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue