summaryrefslogtreecommitdiffstats
path: root/Lib/plat-riscos/riscosenviron.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-03-02 05:58:11 (GMT)
committerGuido van Rossum <guido@python.org>2001-03-02 05:58:11 (GMT)
commit228d80736c39e41a6b46dad211df0ba871b0c8f8 (patch)
treec15c8ecf8664d6c225b6d2f2821068c31e2302d8 /Lib/plat-riscos/riscosenviron.py
parentc92cdf7aa770ee84a2c8e8f219fde4889e5adc92 (diff)
downloadcpython-228d80736c39e41a6b46dad211df0ba871b0c8f8.zip
cpython-228d80736c39e41a6b46dad211df0ba871b0c8f8.tar.gz
cpython-228d80736c39e41a6b46dad211df0ba871b0c8f8.tar.bz2
RISCOS files by dschwertberger
Diffstat (limited to 'Lib/plat-riscos/riscosenviron.py')
-rw-r--r--Lib/plat-riscos/riscosenviron.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/Lib/plat-riscos/riscosenviron.py b/Lib/plat-riscos/riscosenviron.py
new file mode 100644
index 0000000..d44aa0a
--- /dev/null
+++ b/Lib/plat-riscos/riscosenviron.py
@@ -0,0 +1,46 @@
+"""A more or less complete user-defined wrapper around dictionary objects."""
+
+import riscos
+
+class _Environ:
+ def __init__(self):
+ pass
+ def __repr__(self):
+ return repr(riscos.getenvdict())
+ def __cmp__(self, dict):
+ if isinstance(dict, UserDict):
+ return cmp(riscos.getenvdict(), dict)
+ def __len__(self):
+ return len(riscos.getenvdict())
+ def __getitem__(self, key):
+ ret = riscos.getenv(key)
+ if ret<>None:
+ return ret
+ else:
+ raise KeyError
+ def __setitem__(self, key, item):
+ riscos.setenv(key, item)
+ def __delitem__(self, key):
+ riscos.delenv(key)
+ def clear(self):
+ # too dangerous on RISC OS
+ pass
+ def copy(self):
+ return riscos.getenvdict()
+ def keys(self): return riscos.getenvdict().keys()
+ def items(self): return riscos.getenvdict().items()
+ def values(self): return riscos.getenvdict().values()
+ def has_key(self, key):
+ value = riscos.getenv(key)
+ return value<>None
+ def update(self, dict):
+ for k, v in dict.items():
+ riscos.putenv(k, v)
+ def get(self, key, failobj=None):
+ value = riscos.getenv(key)
+ if value<>None:
+ return value
+ else:
+ return failobj
+
+environ = _Environ()