X Tutup
Skip to content

Commit 247759e

Browse files
committed
First hg commit after moving from git: added dark magic to prevent
__getattribute__ being called when showing autocomplete options
0 parents  commit 247759e

File tree

13 files changed

+2644
-0
lines changed

13 files changed

+2644
-0
lines changed

.pycheckrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
blacklist = ['pyparsing', 'code', 'pygments/lexer']

CHANGELOG

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
v0.7.2
2+
======
3+
Menno sent me some patches to fix some stuff:
4+
* Socket error handled when submitting to a pastebin.
5+
* Resizing could crash if you resize small enough.
6+
7+
'self' in arg list is now highlighted a different colour.
8+
9+
flush_output option added to config to control whether output is flushed to
10+
stdout or not on exit.
11+
12+
Piping something to bpython made it lock up as stdin was not the keyboard -
13+
bpython just executes stdin and exits instead of trying to do something clever.
14+
15+
Mark Florisson (eggy) gave me a patch that stops weird breakage when unicode
16+
objects get added into the output buffer - they now get encoded into the output
17+
encoding.
18+
19+
Bohdan Vlasyuk sent me a patch that fixes a problem with the above patch from
20+
Mark if sys.__stdout__.encoding didn't exist.
21+
22+
Save to file now outputs executable code (i.e. without the >>> and ... and with
23+
"# OUT: " prepended to all output lines). I never used this feature much but
24+
someone asked for this behaviour.
25+
26+
v0.7.1
27+
======
28+
Added support for a history file, defaults to ~/.pythonhist and 100 lines but
29+
is configurable from the rc file (see sample-rc).
30+
31+
Charles Duffy has added a yank/put thing - C-k and C-y. He also ran the code
32+
through some PEP-8 checker thing and fixed up a few old habits I manage to
33+
break but didn't manage to fix the code to reflect this - thank you!
34+
35+
Jørgen Tjernø has fixed up the autoindentation issues we encountered when
36+
bringing soft tabs in.
37+
38+
SyntaxError, ValueError and OverflowError are now caught properly
39+
(code.InteractiveInterpreter treats these as different to other exceptions as
40+
it doesn't print the whole traceback, so a different handler is called). This
41+
was discovered as I was trying to stop autoindentation from occurring on a
42+
SyntaxError, which has also been fixed.
43+
44+
'.' now in sys.path on startup.
45+
46+
v0.7.0
47+
======
48+
C-d behaviour changed so it no longer exits if the current line isn't empty.
49+
50+
Extra linebreak added to end of stdout flush.
51+
52+
pygments and pyparsing are now dependencies.
53+
54+
Jørgen Tjernø has done lots of cool things like write a manpage and .desktop
55+
file and improved the way tabbing works and also added home, end and del key
56+
handling as well as C-w for deleting words - thanks a lot!
57+
58+
raw_input() and all its friends now work fine.
59+
60+
PYTHONSTARTUP handled without blowing up on stupid errors (it now parses the
61+
file at once instead of feeding it to the repl line-by-line).
62+
63+
v0.6.4
64+
======
65+
KeyboardInterrupt handler clears the list window properly now.
66+
67+
v0.6.3
68+
======
69+
Forgot to switch rpartition to split for 2.4 compat.
70+
71+
v0.6.2
72+
======
73+
The help() now works (as far as I can see) exactly the same
74+
as the vanilla help() in the regular interpreter. I copied some
75+
code from pydoc.py to make it handle the special cases, e.g.
76+
help('keywords')
77+
help('modules')
78+
etc.
79+
80+
v0.6.1
81+
======
82+
Somehow it escaped my attention that the list window was never
83+
fully using the rightmost column, except for the first row. This
84+
is because me and numbers don't have the best relationship. I think
85+
stability is really improving with the latest spat of bugfixes,
86+
keep me informed of any bugs.
87+
88+
v0.6.0
89+
======
90+
No noticeable changes except that bpython should now work with
91+
Python 2.4. Personally I think it's silly to make a development
92+
tool work with an out of date version of Python but some people
93+
seem to disagree. The only real downside is that I had to do a
94+
horrible version of all() using reduce(), otherwise there's no
95+
real differences in the code.
96+
97+
v0.5.3
98+
======
99+
Now you can configure a ~/.bpythonrc file (or pass a rc file at the
100+
command line (bpython /foo/bar). See README for details.
101+
102+
v0.5.2
103+
======
104+
help() actually displays the full help page, and I fixed up the
105+
ghetto pager a little.
106+
107+
v0.5.1
108+
======
109+
Now you can hit tab to display the autocomplete list, rather than
110+
have it pop up automatically as you type which, apparently, annoys
111+
Brendogg.
112+
113+
v0.5.0
114+
======
115+
A few people have commented that the help() built-in function
116+
doesn't work so well with bpython, since Python will try to output
117+
the help string to PAGER (usually "less") which obviously makes
118+
everything go wrong when curses is involved. With a bit of hackery
119+
I've written my own ghetto pager and injected my own help function
120+
into the interpreter when it initialises in an attempt to rectify this.
121+
As such, it's pretty untested but it seems to be working okay for me.
122+
Suggestions/bug reports/patches are welcome regarding this.
123+
124+
v0.4.2
125+
======
126+
Well, hopefully we're one step closer to making the list sizing
127+
stuff work. I really hate doing code for that kind of thing as I
128+
never get it quite right, but with perseverence it should end up
129+
being completely stable; it's not the hardest thing in the world.
130+
131+
Various cosmetic fixes have been put in at the request of a bunch
132+
of people who were kind enough to send me emails regarding their
133+
experiences.
134+
135+
PYTHONSTARTUP is now dealt with and used properly, as per the vanilla
136+
interpreter.
137+
138+
v0.4.1
139+
======
140+
It looks like the last release was actually pretty bug-free, aside
141+
from one tiny bug that NEVER ACTUALLY HAPPENS but someone was bugging
142+
me about it anyway, oh well.
143+
144+
v0.4.0
145+
======
146+
It's been quite a long time since the last update, due to several
147+
uninteresting and invalid excuses, but I finally reworked the list
148+
drawing procedures so the crashing seems to have been taken care of
149+
to an extent. If it still crashes, the way I've written it will hopefully
150+
allow a much more robust way of fixing it, one that might actually work.
151+
152+
v0.3.2
153+
======
154+
Thanks to Aaron Gallagher for pointing out a case where the hugely
155+
inefficient list generation routines were actually making a significant
156+
issue; they're much more efficient now and should hopefully not cause
157+
any more problems.
158+
159+
v0.3.1
160+
======
161+
Thanks to Klaus Alexander Seis for the expanduser() patch.
162+
Auto indent works on multiple levels now.
163+
164+
v0.3.0
165+
======
166+
Now with auto-indent. Let me know if it's annoying.
167+
168+
v0.2.4
169+
======
170+
Thanks a lot to Angus Gibson for submitting a patch to fix a problem
171+
I was having with initialising the keyboard stuff in curses properly.
172+
173+
Also a big thanks to John Beisley for providing the patch that shows
174+
a class __init__ method's argspec on class instantiation.
175+
176+
I've fixed up the argspec display so it handles really long argspecs
177+
(e.g. subprocess.Popen()) and doesn't crash if something horrible
178+
happens (rather, it avoids letting something horrible happen).
179+
180+
I decided to add a key that will get rid of the autocomplete window,
181+
since it can get in the way. C-l seemed like a good choice, since
182+
it would work well as a side-effect of redrawing the screen (at
183+
least that makes sense to me). In so doing I also cleaned up a lot
184+
of the reevaluating and resizing code so that a lot of the strange
185+
output seen on Rewind/resize seems to be gone.
186+
187+
v0.2.3
188+
======
189+
The fix for the last bug broke the positioning of the autocomplete
190+
box, whoops.
191+
192+
v0.2.2
193+
======
194+
That pesky bug keeps coming up. I think it's finally nailed but
195+
it's just a matter of testing and hoping. I hate numbers.
196+
197+
v0.2.1
198+
======
199+
I'm having a bit of trouble with some integer division that's
200+
causing trouble when a certain set of circumstances arise,
201+
and I think I've taken care of that little bug, since it's
202+
a real pain in the ass and only creeps up when I'm actually
203+
doing something useful, so I'll test it for a bit and release
204+
it as hopefully a bug fixed version.
205+
206+
v0.2.0
207+
======
208+
A little late in the day to start a changelog, but here goes...
209+
This version fixed another annoying little bug that was causing
210+
crashes given certain exact circumstances. I always find it's the
211+
way with curses and sizing of windows and things...
212+
213+
I've also got bpython to try looking into pydoc if no matches
214+
are found for the argspec, which means the builtins have argspecs
215+
too now, hooray.

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License
2+
3+
Copyright (c) 2008 Bob Farrell
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.
22+

MANIFEST.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include .gitignore
2+
include .pycheckrc
3+
include CHANGELOG
4+
include LICENSE
5+
include data/bpython.desktop
6+
include doc/*.[0-9]
7+
include sample.rc

README

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
bpython - A fancy curses interface to the Python interactive interpreter
2+
=======
3+
4+
Dependencies
5+
============
6+
Pygments
7+
pyparsing
8+
(apt-get install python-pyparsing python-pygments)
9+
10+
Introduction
11+
============
12+
A few people asked for stuff like syntax highlighting
13+
and autocomplete for the Python interactive interpreter.
14+
IPython seems to offer this (plus you can get readline
15+
behaviour in the vanilla interpreter) but I tried
16+
IPython a couple of times. Perhaps I didn't really get
17+
it, but I get the feeling that the ideas behind IPython
18+
are pretty different to bpython. I didn't want to create
19+
a whole development environment; I simply wanted to
20+
provide a couple of neat features that already exist
21+
and turn them into something a little more interactive.
22+
23+
The idea is to provide the user with all the features
24+
in-line, much like modern IDEs, but in a simple,
25+
lightweight package that can be run in a terminal
26+
window, so curses seemed like the best choice.
27+
Sorry if you use Windows.
28+
29+
bpython doesn't attempt to create anything new or
30+
groundbreaking, it simply brings together a few neat
31+
ideas and focuses on practicality and usefulness.
32+
For this reason, the "Rewind" function should be
33+
taken with a pinch of salt, but personally I have
34+
found it to be very useful. I use bpython now
35+
whenever I would normally use the vanilla interpreter,
36+
e.g. for testing out solutions to people's problems
37+
on IRC, quickly testing a method of doing something
38+
without creating a temporary file, etc..
39+
40+
I hope you find it useful and please feel free to
41+
submit any bugs/patches (yeah right)/suggestions
42+
to:
43+
robertanthonyfarrell@gmail.com
44+
45+
Features
46+
========
47+
48+
* In-line syntax highlighting.
49+
This uses Pygments for lexing the code as you type,
50+
and colours appropriately. Pygments does a great job
51+
of doing all of the tricky stuff and really leaving
52+
me with very little to do except format the tokens
53+
in all my favourite colours.
54+
55+
* Readline-like autocomplete with suggestions displayed
56+
as you type.
57+
Thanks to Python's readline interface to libreadline
58+
and a ready-made class for using a Python interpreter's
59+
scope as the dataset, the only work here was displaying
60+
the readline matches as you type in a separate curses
61+
window below/above the cursor.
62+
63+
* Expected parameter list.
64+
As in a lot of modern IDEs, bpython will attempt to
65+
display a list of parameters for any function you
66+
call. The inspect module is tried first, which works
67+
with any Python function, and then pydoc if that fails,
68+
which seems to be pretty adequate, but obviously
69+
in some cases it's simply not possible. I used pyparsing
70+
to cure my nested parentheses woes; again, it was
71+
nice and easy.
72+
73+
* Rewind.
74+
I didn't call this "Undo" because I thought that would
75+
be misleading, but "Rewind" is probably as bad. The
76+
idea is that the code entered is kept in memory and
77+
when the Rewind function is called, the last line is
78+
popped and the entire code is re-evaluated. As you can
79+
imagine, this has a lot of potential problems, but for
80+
defining classes and functions, I've found it to be
81+
nothing but useful.
82+
83+
* Pastebin code/write to file.
84+
I don't really use the save thing much, but the pastebin
85+
thing's great. Hit a key and what you see on the screen
86+
will be sent to a pastebin and a URL is returned for you
87+
to do what you like with. I've hardcoded rafb.net/paste
88+
in for now, that needs to be fixed so it's configurable.
89+
Next release, I promise.
90+
91+
* Flush curses screen to stdout.
92+
A featurette, perhaps, but I thought it was worth noting.
93+
I can't personally recall a curses app that does this,
94+
perhaps it's often not useful, but when you quit bpython,
95+
the screen data will be flushed to stdout, so it basically
96+
looks the same as if you had quit the vanilla interpreter.
97+
98+
Configuration
99+
=============
100+
See the sample-rc file for a list of available options.
101+
You should save your rc file as ~/.bpythonrc or specify
102+
at the command line:
103+
104+
bpython /path/to/bpythonrc
105+
106+
Known Bugs
107+
==========
108+
109+
* Triple quoted strings over multiple lines work, but they're
110+
not highlighted properly.

bpython/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# The MIT License
2+
#
3+
# Copyright (c) 2008 Bob Farrell
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.

0 commit comments

Comments
 (0)
X Tutup