summaryrefslogtreecommitdiffstats
path: root/Lib/site.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-09-05 04:39:55 (GMT)
committerGuido van Rossum <guido@python.org>2000-09-05 04:39:55 (GMT)
commitd1252395bd697b2f2b2f461c1078fda22ab739b1 (patch)
treeb99429d30749c9920ca9a4fa7377b310c6b9772a /Lib/site.py
parentf2ffce05180d1aa3fd71d5d42d2f0b1b698b6b05 (diff)
downloadcpython-d1252395bd697b2f2b2f461c1078fda22ab739b1.zip
cpython-d1252395bd697b2f2b2f461c1078fda22ab739b1.tar.gz
cpython-d1252395bd697b2f2b2f461c1078fda22ab739b1.tar.bz2
Add new builtin commands "copyright", "license", "credits" which
display the information you would expect them to display.
Diffstat (limited to 'Lib/site.py')
-rw-r--r--Lib/site.py53
1 files changed, 52 insertions, 1 deletions
diff --git a/Lib/site.py b/Lib/site.py
index b69d30d..1c25f50 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -119,7 +119,58 @@ import __builtin__
__builtin__.quit = __builtin__.exit = exit
del exit
-#
+# interactive prompt objects for printing the license text, a list of
+# contributors and the copyright notice.
+class _Printer:
+ MAXLINES = 23
+
+ def __init__(self, s):
+ self.__lines = s.split('\n')
+ self.__linecnt = len(self.__lines)
+
+ def __repr__(self):
+ prompt = 'Hit Return for more, or q (and Return) to quit: '
+ lineno = 0
+ while 1:
+ try:
+ for i in range(lineno, lineno + self.MAXLINES):
+ print self.__lines[i]
+ except IndexError:
+ break
+ else:
+ lineno += self.MAXLINES
+ key = None
+ while key is None:
+ key = raw_input(prompt)
+ if key not in ('', 'q'):
+ key = None
+ if key == 'q':
+ break
+ return ''
+
+__builtin__.copyright = _Printer(sys.copyright)
+__builtin__.credits = _Printer(
+ '''Python development is led by BeOpen PythonLabs (www.pythonlabs.com).''')
+
+def make_license(filename):
+ try:
+ return _Printer(open(filename).read())
+ except IOError:
+ return None
+
+here = os.path.dirname(os.__file__)
+for dir in here, os.path.join(here, os.pardir), os.curdir:
+ for file in "LICENSE.txt", "LICENSE":
+ lic = make_license(os.path.join(dir, file))
+ if lic:
+ break
+ if lic:
+ __builtin__.license = lic
+ break
+else:
+ __builtin__.license = _Printer('See http://hdl.handle.net/1895.22/1012')
+
+
# Set the string encoding used by the Unicode implementation. The
# default is 'ascii', but if you're willing to experiment, you can
# change this.