http://bitbucket.org/pavpanchekha/bpython-oranj/

Python is now a bit broken (no attr matching), oranj just as good (use
--oranj command line flag).

Because I've yet to make a build system thing for oranj, the following
directory tree is required:

oranj
 - folder
   - bpython
 - src
 - ...

folder can be called anything.

I should really fix that.

On May 13, 2:22 pm, Bob Farrell <[email protected]>
wrote:
> Well, there's some hideously dark magic that goes on with the autocompletion
> stuff which you might want to bypass. Feel free to send a patch over (or,
> ideally, if you can fork the bpython project on bitbucket.org so I can pull 
> and
> push without having to worry about emailing patch files around) and I'll take 
> a
> look. I'm at work, may as well do something interesting. :)
>
>
>
> On Wed, May 13, 2009 at 05:58:47AM -0700, Pavel Panchekha wrote:
>
> > Hmm. I have it mostly working, but I seem to have completely broken
> > attribute matching. Don't know why, and can't seem to be able to debug
> > anything. If you want, I can send you a patch as it is now, maybe you
> > will understand better than me. Don't want to waste your time though.
>
> > What I have right now is that I split out all of the language specific
> > stuff completely, and everything but the attribute matching works (Oh,
> > and I haven't tested rewind, but that shouldn't be a problem).
>
> > On May 13, 9:46 am, Bob Farrell <[email protected]>
> > wrote:
> > > Hi Pavel,
>
> > > On Tue, May 12, 2009 at 05:58:13PM -0700, Pavel Panchekha wrote:
>
> > > > Having a bit of trouble here with the color formatting. The
> > > > BPythonFormatter works (mostly, had to fix it up a bit) but there's
> > > > another issue.
>
> > > > When Oranj prints error messages, it'd be nice if they were colored.
> > > > They already are when using the console, but I need to use the curses
> > > > color codes for printing in the bpython.
>
> > > > What I'm doing is this:
>
> > > > msg = "\x01r\x03%s\x01d\x03%s" % (type(e).__name__, ("" if not e.args
> > > > else (": " + " ".join(map(str, e.args)))))
>
> > > > Ideally, this should make the first bit (type(e).__name__) red and the
> > > > other bit normal gray colored (Its the error message). This isn't
> > > > working, however - the entire line is red.
>
> > > I thought this was already possible, but turns out it wasn't - I've 
> > > changed the
> > > code so that you can achieve what you were aiming for now by doing this:
> > >     msg = "\x01r\x03what\x04\x01d\x03hello"
> > > and then passing that to Repl.write, which will now split on \x04 - 
> > > you'll have
> > > to pull from the hg repo to get the latest changes, or just use this:
>
> > >     def write(self, s):
> > >         """For overriding stdout defaults"""
> > >         if '\x04' in s:
> > >             for block in s.split('\x04'):
> > >                 self.write(block)
> > >             return
> > >         if s.rstrip() and '\x03' in s:
> > >             t = s.split('\x03')[1]
> > >         else:
> > >             t = s
>
> > >         if isinstance(t, unicode):
> > >             t = t.encode(getattr(sys.__stdout__, 'encoding') or 
> > > sys.getdefaultencoding())
>
> > >         if not self.stdout_hist:
> > >             self.stdout_hist = t
> > >         else:
> > >             self.stdout_hist += t
>
> > >         self.echo(s)
> > >         self.s_hist.append(s.rstrip())
>
> > > The more I look at the way the colours work in bpython, the more I hate 
> > > it. Oh
> > > well. :)
>
> > > > Anything I'm doing wrong? I could send complete, (sorta) working code
> > > > if you want, but in any case, is there anything obviously wrong?
>
> > > > On May 12, 5:06 pm, Pavel Panchekha <[email protected]> wrote:
> > > > > Thanks for the rundown. It shouldn't be too hard - most of the stuff
> > > > > you mentioned is already there in a half-done way, just need to clean
> > > > > it up. With luck, I'll extract the python-specific bits as I go, so it
> > > > > can be merged upstream. I'll try to keep the mailing list posted if I
> > > > > finish up.
>
> > > > > On May 12, 4:53 pm, Bob Farrell <[email protected]>
> > > > > wrote:
>
> > > > > > Hi Pavel,
>
> > > > > > On Tue, May 12, 2009 at 11:01:05AM -0700, Pavel Panchekha wrote:
>
> > > > > > > I'd like to write a shell for oranj similar to bpython. I've 
> > > > > > > already
> > > > > > > written a pygments parser for it, and writing completion 
> > > > > > > shouldn't be
> > > > > > > too hard. What else needs to be changed before I can get a full
> > > > > > > bpython-esque shell for oranj? Is there anything in curses to 
> > > > > > > fiddle
> > > > > > > with, for example? (I tried just replacing PythonLexer with
> > > > > > > OranjLexer, but it doesn't seem to work)
>
> > > > > > > Oranj:http://github.com/pavpanchekha/oranj/tree/master
> > > > > > > OranjLexer:http://dev.pocoo.org/projects/pygments/ticket/409
>
> > > > > > I tried downloading it and running it (seems it depends on 2.6) 
> > > > > > but, since I
> > > > > > didn't have readline built against my 2.6 build, it errored - you 
> > > > > > try to import
> > > > > > readline, pass on an ImportError and then refer to it anyway.
>
> > > > > > Anyway, so I've rebuilt my python2.6 and got it working.
>
> > > > > > It looks to me like you'd be best off using bpython pretty much 
> > > > > > as-is and
> > > > > > providing something similar to the "code" module for oranj, i.e. a 
> > > > > > way of
> > > > > > executing oranj code from any Python program. Here's how bpython 
> > > > > > uses it:
>
> > > > > >     def push(self, s):
> > > > > >         """Push a line of code onto the buffer so it can process it 
> > > > > > all
> > > > > >         at once when a code block ends"""
> > > > > >         s = s.rstrip('\n')
> > > > > >         self.buffer.append(s)
>
> > > > > >         try:
> > > > > >             more = self.interp.runsource("\n".join(self.buffer))
> > > > > >         except SystemExit:
> > > > > >             # Avoid a traceback on e.g. quit()
> > > > > >             self.do_exit = True
> > > > > >             return False
>
> > > > > >         if not more:
> > > > > >             self.buffer = []
>
> > > > > >         return more
>
> > > > > > "self.interp" in this case is one of these:
>
> > > > > >     class Interpreter(code.InteractiveInterpreter):
>
> > > > > > So, if you can make a Python module that mimics the code module (at 
> > > > > > least the
> > > > > > part of it that bpython uses) then you should be able to swap out 
> > > > > > the Python
> > > > > > code module with your one, change the lexer it being used, do your 
> > > > > > own
> > > > > > autocompletion routines and everything should hopefully Just Work.
>
> > > > > > You might also want to try to mimic the behaviour of 
> > > > > > inspect.getargspec, since
> > > > > > bpython uses that to show what arguments a function is expecting.
>
> > > > > > I can't think of anything else right now, but if you have any more 
> > > > > > questions
> > > > > > feel free to ask. Also if you think you can make the necessary 
> > > > > > changes to
> > > > > > bpython and still keep it 100% compatible with its current 
> > > > > > functionality (i.e.
> > > > > > if you can make it so anyone could come along and plug in their own 
> > > > > > module to
> > > > > > make it work with some other language) then I'd be happy to bring 
> > > > > > that
> > > > > > upstream. Otherwise, you are of course encouraged to fork it. :)
>
> > > > > > Good luck !
>
> > > --
> > > Bob Farrell
>
> --
> Bob Farrell
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"bpython" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/bpython?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to