better autocomplete in web2pu shell

This commit is contained in:
mdipierro
2013-07-28 05:47:36 -05:00
parent 18bed27bae
commit abeb4541fe
4 changed files with 30 additions and 12 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.6.0-development+timestamp.2013.07.27.06.46.34
Version 2.6.0-development+timestamp.2013.07.28.05.46.47
+5
View File
@@ -122,6 +122,8 @@
'edit views:': 'modifica viste (view):',
'Editing bigul': 'Editing bigul',
'Editing file "%s"': 'Modifica del file "%s"',
'Editing italo': 'Editing italo',
'Editing italo3': 'Editing italo3',
'Editing Language file': 'Modifica file linguaggio',
'Enterprise Web Framework': 'Enterprise Web Framework',
'Error logs for "%(app)s"': 'Log degli errori per "%(app)s"',
@@ -205,6 +207,7 @@
'NO': 'NO',
'No databases in this application': 'Nessun database presente in questa applicazione',
'no match': 'nessuna corrispondenza',
'no package selected': 'no package selected',
'online designer': 'online designer',
'or alternatively': 'or alternatively',
'Or Get from URL:': 'Or Get from URL:',
@@ -257,6 +260,7 @@
'selected': 'selezionato',
'session': 'session',
'session expired': 'sessions scaduta',
'Set Breakpoint on %s at line %s: %s': 'Set Breakpoint on %s at line %s: %s',
'shell': 'shell',
'Site': 'sito',
'some files could not be removed': 'non è stato possibile rimuovere alcuni files',
@@ -269,6 +273,7 @@
'Stylesheet': 'Foglio di stile (stylesheet)',
'Submit': 'Submit',
'submit': 'invia',
'successful': 'successful',
'Sure you want to delete this object?': 'Vuoi veramente cancellare questo oggetto?',
'table': 'tabella',
'test': 'test',
+2 -1
View File
@@ -23,7 +23,7 @@
'Administrative Interface': 'Interfaccia Amministrativa',
'Administrative interface': 'Interfaccia amministrativa',
'Ajax Recipes': 'Ajax Recipes',
'An error occured, please %s the page': "È stato rilevato un errore, prego %s la pagina",
'An error occured, please %s the page': 'È stato rilevato un errore, prego %s la pagina',
'And': 'E',
'appadmin is disabled because insecure channel': 'Amministrazione (appadmin) disabilitata: comunicazione non sicura',
'Are you sure you want to delete this object?': 'Sicuro di voler cancellare questo oggetto ?',
@@ -82,6 +82,7 @@
'Edit This App': 'Modifica questa applicazione',
'Email and SMS': 'Email e SMS',
'Email non valida': 'Email non valida',
'enter a number between %(min)g and %(max)g': 'enter a number between %(min)g and %(max)g',
'enter an integer between %(min)g and %(max)g': 'inserisci un intero tra %(min)g e %(max)g',
'Errors': 'Errori',
'Errors in form, please check it out.': 'Errori nel form, ricontrollalo',
+22 -10
View File
@@ -30,6 +30,25 @@ from dal import BaseAdapter
logger = logging.getLogger("web2py")
def enable_autocomplete_and_history(adir,env):
try:
import rlcompleter
import atexit
import readline
except ImportError:
pass
else:
readline.parse_and_bind("bind ^I rl_complete"
if sys.platform == 'darwin'
else "tab: complete")
history_file = os.path.join(adir,'.pythonhistory')
try:
readline.read_history_file(history_file)
except IOError:
open(history_file, 'a').close()
atexit.register(readline.write_history_file, history_file)
readline.set_completer(rlcompleter.Completer(env).complete)
def exec_environment(
pyfile='',
@@ -159,8 +178,7 @@ def run(
import_models=False,
startfile=None,
bpython=False,
python_code=False
):
python_code=False):
"""
Start interactive shell or run Python script (startfile) in web2py
controller environment. appname is formatted like:
@@ -174,6 +192,7 @@ def run(
if not a:
die(errmsg)
adir = os.path.join('applications', a)
if not os.path.exists(adir):
if sys.stdin and not sys.stdin.name == '/dev/null':
confirm = raw_input(
@@ -271,14 +290,7 @@ def run(
except:
logger.warning(
'import IPython error; use default python shell')
try:
import readline
import rlcompleter
except ImportError:
pass
else:
readline.set_completer(rlcompleter.Completer(_env).complete)
readline.parse_and_bind('tab:complete')
enable_autocomplete_and_history(adir,_env)
code.interact(local=_env)