Accepting request 750329 from home:mcepl:branches:devel:languages:python:Factory

Run spec-cleaner against the SPEC file.

OBS-URL: https://build.opensuse.org/request/show/750329
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:Factory/shared-python-startup?expand=0&rev=1
This commit is contained in:
Tomáš Chvátal
2019-12-02 07:49:11 +00:00
committed by Git OBS Bridge
commit 402d25390b
6 changed files with 378 additions and 0 deletions

38
pythonstart Normal file
View File

@@ -0,0 +1,38 @@
# startup script for python to enable saving of interpreter history and
# enabling name completion
# import needed modules
import atexit
import os
import readline
import rlcompleter
import sys
# where is history saved
ver = "%d.%d" % sys.version_info[:2]
historyPath = os.path.expanduser("~/.pyhistory%s" % ver)
# handler for saving history
def save_history(historyPath=historyPath):
try:
readline.write_history_file(historyPath)
except:
pass
# read history, if it exists
if os.path.exists(historyPath):
readline.set_history_length(10000)
readline.read_history_file(historyPath)
# register saving handler
atexit.register(save_history)
# enable completion
readline.parse_and_bind('tab: complete')
# cleanup
del os, atexit, readline, rlcompleter, save_history, historyPath
# vim:set ft=python: