I need to implement an IAdminCommandProvider component, and I failed
to understand what the "complete" feature actually does.
It seems it is used from the TracAdmin.complete_line() method, which
is itself invoked from:
* TracAdmin.complete_help()
* TracAdmin.completedefault()
* TracAdmin.completenames()
However I cannot find any call to these methods. What am I missing?
Moreover, I cannot trigger an autocompletion from the tracadmin
command line. How to use it?
Thanks,
Manu
This is done by the base class, cmd.Cmd.
You don't need to understand how it works, though. Just implement the
required completion functions, looking at some of the existing commands
like trac.wiki.admin.WikiAdmin as an example.
> Moreover, I cannot trigger an autocompletion from the tracadmin
> command line. How to use it?
Auto-completion should be triggered by the "Tab" key. On Windows, IIRC
you need to install pyreadline:
http://pypi.python.org/pypi/pyreadline
-- Remy
As I was unable to make it work, I started to look at the code. ;-)
> Auto-completion should be triggered by the "Tab" key. On Windows, IIRC
> you need to install pyreadline:
It seems it does not work for me (Mac OS X 10.6.7).
import readline
is successful from an interactive Python shell.
Is there some specific configuration (such as the terminal type) to
make it work on Mac OS X?
Thanks,
Manu
Not that I know of. It's working fine here (Mac OS X 10.5.?), but I'm
using Python from MacPorts, so I don't know about the stock installed
Python.
-- Remy
Ok, it does not work with the system Python, but it works fine with
the Homebrew Python.
Thanks,
Manu
Follow up:
To make it work with the system Python, the Python readline library
should be used (this is a Mac OS X specific issue, as Mac OS X is
shipped with libedit instead of GNU readline), see
http://pypi.python.org/pypi/readline
1/ Install this package with easy_install (not with pip, or you'll
have to deal with a sys.path inclusion order issue):
sudo easy_install readline
2/ Check out your installation
python
import readline
readline.__file__
should report the newly installed readline library (/Library/...)
if it reports the system library (/System/Library/...) the defaut
readline module will be used, and tab completion will not work.
HTH,
Manu
--
You received this message because you are subscribed to the Google Groups "Trac Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-dev+unsubscribe@googlegroups.com.
To post to this group, send email to trac...@googlegroups.com.
Visit this group at https://groups.google.com/group/trac-dev.
For more options, visit https://groups.google.com/d/optout.
Hi Ryan,I have not used trac on OSX for a while, but I’ve extracted the command line interpreter from trac-admin to test-drive several IoT projects.I’m not using Python 2.x either (AFAICT, among the numerous Python projects/modules I use on a regular basis, Trac is the only one that still requires Python 2.x :-)).However, whenever I need Python on macOs, whether it’s Python 2.7.x or Python 3.x, I install it from (home)brew, and I now always use the excellent pyreadline library in replacement of the native GNU readline - another native dependency dropped for a pure Python module.One special attention with brew is that it’s quite easy to break a working installation, when the minor Python version is automatically updated (from 3.5 to 3.6 for example). Either the Python installation needs to be pinned down (‘brew pin’) or the proper virtual env should be set up.
The snippet that goes into the equivalent of console.py now looks like:try:import readline as rlexcept ImportError:try:import pyreadline as rlexcept ImportError:rl = NoneI’ve observed no regression while using the Python implementation vs. the native library.
The snippet that goes into the equivalent of console.py now looks like:try:import readline as rlexcept ImportError:try:import pyreadline as rlexcept ImportError:rl = NoneI’ve observed no regression while using the Python implementation vs. the native library.
That looks interesting. We could reorder the operations to prefer pyreadline when installed:try:import pyreadline as rlexcept ImportError:try:import readline as rlexcept ImportError:rl = None