More release readiness fixes.
This commit is contained in:
parent
e049bc3f40
commit
4143459daf
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,6 @@
|
|||||||
*.pyc
|
*.pyc
|
||||||
*~
|
*~
|
||||||
.*.sw[op]
|
.*.sw[op]
|
||||||
|
*.egg-info
|
||||||
|
dist
|
||||||
|
build
|
||||||
|
@ -12,7 +12,6 @@ def fermat(n):
|
|||||||
for z in range(1, x**n+y**n + 1):
|
for z in range(1, x**n+y**n + 1):
|
||||||
#from pudb import set_trace; set_trace()
|
#from pudb import set_trace; set_trace()
|
||||||
if x**n + y**n == z**n:
|
if x**n + y**n == z**n:
|
||||||
fuckin
|
|
||||||
yield x, y, z
|
yield x, y, z
|
||||||
|
|
||||||
print "SF", simple_func(10)
|
print "SF", simple_func(10)
|
90
pudb.py
90
pudb.py
@ -44,7 +44,7 @@ License:
|
|||||||
|
|
||||||
PuDB is licensed to you under the MIT/X Consortium license:
|
PuDB is licensed to you under the MIT/X Consortium license:
|
||||||
|
|
||||||
Copyright (c) 2008 Andreas Klöckner
|
Copyright (c) 2009 Andreas Klöckner
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person
|
Permission is hereby granted, free of charge, to any person
|
||||||
obtaining a copy of this software and associated documentation
|
obtaining a copy of this software and associated documentation
|
||||||
@ -239,7 +239,7 @@ class PostSignalWrap(SignalWrap):
|
|||||||
|
|
||||||
|
|
||||||
class SourceLine(urwid.FlowWidget):
|
class SourceLine(urwid.FlowWidget):
|
||||||
def __init__(self, dbg_ui, text, attr):
|
def __init__(self, dbg_ui, text, attr=None):
|
||||||
self.dbg_ui = dbg_ui
|
self.dbg_ui = dbg_ui
|
||||||
self.text = text
|
self.text = text
|
||||||
self.attr = attr
|
self.attr = attr
|
||||||
@ -296,12 +296,11 @@ class SourceLine(urwid.FlowWidget):
|
|||||||
attr = [("source", 2)] + attr
|
attr = [("source", 2)] + attr
|
||||||
|
|
||||||
# clipping ------------------------------------------------------------
|
# clipping ------------------------------------------------------------
|
||||||
|
|
||||||
if len(text) > maxcol:
|
if len(text) > maxcol:
|
||||||
text = text[:maxcol]
|
text = text[:maxcol]
|
||||||
|
attr = rle_subseg(attr, 0, maxcol)
|
||||||
|
|
||||||
# shipout -------------------------------------------------------------
|
# shipout -------------------------------------------------------------
|
||||||
|
|
||||||
from urwid.util import apply_target_encoding
|
from urwid.util import apply_target_encoding
|
||||||
txt, cs = apply_target_encoding(text)
|
txt, cs = apply_target_encoding(text)
|
||||||
|
|
||||||
@ -315,7 +314,7 @@ class SourceLine(urwid.FlowWidget):
|
|||||||
|
|
||||||
class DebuggerUI(object):
|
class DebuggerUI(object):
|
||||||
CAPTION_TEXT = (u"PuDB - The Python Urwid debugger - F1 for help"
|
CAPTION_TEXT = (u"PuDB - The Python Urwid debugger - F1 for help"
|
||||||
u" - © Andreas Klöckner 2008")
|
u" - © Andreas Klöckner 2009")
|
||||||
|
|
||||||
def __init__(self, dbg):
|
def __init__(self, dbg):
|
||||||
self.debugger = dbg
|
self.debugger = dbg
|
||||||
@ -482,9 +481,16 @@ class DebuggerUI(object):
|
|||||||
|
|
||||||
def run_shell(w, size, key):
|
def run_shell(w, size, key):
|
||||||
self.screen.stop()
|
self.screen.stop()
|
||||||
|
|
||||||
|
if not hasattr(self, "shell_ret_message_shown"):
|
||||||
|
banner = "Hit Ctrl-D to return to PuDB."
|
||||||
|
self.shell_ret_message_shown = True
|
||||||
|
else:
|
||||||
|
banner = ""
|
||||||
|
|
||||||
loc = self.debugger.curframe.f_locals
|
loc = self.debugger.curframe.f_locals
|
||||||
cons = MyConsole(loc)
|
cons = MyConsole(loc)
|
||||||
cons.interact("")
|
cons.interact(banner)
|
||||||
self.screen.start()
|
self.screen.start()
|
||||||
|
|
||||||
class RHColumnFocuser:
|
class RHColumnFocuser:
|
||||||
@ -541,10 +547,27 @@ class DebuggerUI(object):
|
|||||||
raise RuntimeError, "no valid current file"
|
raise RuntimeError, "no valid current file"
|
||||||
|
|
||||||
def pick_module(w, size, key):
|
def pick_module(w, size, key):
|
||||||
|
from os.path import splitext
|
||||||
|
|
||||||
|
def mod_exists(mod):
|
||||||
|
if not hasattr(mod, "__file__"):
|
||||||
|
return False
|
||||||
|
filename = mod.__file__
|
||||||
|
|
||||||
|
base, ext = splitext(filename)
|
||||||
|
ext = ext.lower()
|
||||||
|
|
||||||
|
from os.path import exists
|
||||||
|
|
||||||
|
if ext == ".pyc":
|
||||||
|
return exists(base+".py")
|
||||||
|
else:
|
||||||
|
return ext == ".py"
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
modules = sorted(name
|
modules = sorted(name
|
||||||
for name, mod in sys.modules.iteritems()
|
for name, mod in sys.modules.iteritems()
|
||||||
if hasattr(mod, "__file__"))
|
if mod_exists(mod))
|
||||||
|
|
||||||
def build_filtered_mod_list(filt_string=""):
|
def build_filtered_mod_list(filt_string=""):
|
||||||
return [urwid.AttrWrap(SelectableText(mod),
|
return [urwid.AttrWrap(SelectableText(mod),
|
||||||
@ -564,9 +587,10 @@ class DebuggerUI(object):
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
edit = FilterEdit("Filter: ")
|
edit = FilterEdit([("label", "Filter: ")])
|
||||||
w = urwid.Pile([
|
w = urwid.Pile([
|
||||||
("flow", edit),
|
("flow", urwid.AttrWrap(edit, "value")),
|
||||||
|
("fixed", 1, urwid.SolidFill()),
|
||||||
urwid.AttrWrap(lb, "selectable")])
|
urwid.AttrWrap(lb, "selectable")])
|
||||||
|
|
||||||
result = self.dialog(w, [
|
result = self.dialog(w, [
|
||||||
@ -579,7 +603,6 @@ class DebuggerUI(object):
|
|||||||
mod = sys.modules[widget.get_text()[0]]
|
mod = sys.modules[widget.get_text()[0]]
|
||||||
filename = self.debugger.canonic(mod.__file__)
|
filename = self.debugger.canonic(mod.__file__)
|
||||||
|
|
||||||
from os.path import splitext
|
|
||||||
base, ext = splitext(filename)
|
base, ext = splitext(filename)
|
||||||
if ext == ".pyc":
|
if ext == ".pyc":
|
||||||
ext = ".py"
|
ext = ".py"
|
||||||
@ -693,7 +716,15 @@ class DebuggerUI(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def setup_palette(screen):
|
def setup_palette(screen):
|
||||||
screen.register_palette([
|
|
||||||
|
if hasattr(urwid.escape, "_fg_attr_xterm"):
|
||||||
|
def add_setting(color, setting):
|
||||||
|
return color
|
||||||
|
else:
|
||||||
|
def add_setting(color, setting):
|
||||||
|
return color+","+setting
|
||||||
|
|
||||||
|
palette = [
|
||||||
("header", "black", "light gray", "standout"),
|
("header", "black", "light gray", "standout"),
|
||||||
|
|
||||||
("breakpoint source", "yellow", "dark red"),
|
("breakpoint source", "yellow", "dark red"),
|
||||||
@ -704,12 +735,14 @@ class DebuggerUI(object):
|
|||||||
("variables", "black", "dark cyan"),
|
("variables", "black", "dark cyan"),
|
||||||
("focused variable", "black", "dark green"),
|
("focused variable", "black", "dark green"),
|
||||||
("return value", "yellow", "dark blue"),
|
("return value", "yellow", "dark blue"),
|
||||||
("focused return value", "white", "light blue"),
|
("focused return value", "white", "dark blue"),
|
||||||
|
|
||||||
("stack", "black", "dark cyan", "standout"),
|
("stack", "black", "dark cyan", "standout"),
|
||||||
("focused frame", "black", "dark green"),
|
("focused frame", "black", "dark green"),
|
||||||
("current frame", "white,bold", "dark cyan"),
|
("current frame", add_setting("white", "bold"),
|
||||||
("focused current frame", "white,bold", "dark green", "bold"),
|
"dark cyan"),
|
||||||
|
("focused current frame", add_setting("white", "bold"),
|
||||||
|
"dark green", "bold"),
|
||||||
|
|
||||||
("breakpoint", "black", "dark cyan"),
|
("breakpoint", "black", "dark cyan"),
|
||||||
("focused breakpoint", "black", "dark green"),
|
("focused breakpoint", "black", "dark green"),
|
||||||
@ -721,16 +754,16 @@ class DebuggerUI(object):
|
|||||||
("focused button", "light cyan", "black"),
|
("focused button", "light cyan", "black"),
|
||||||
|
|
||||||
("background", "black", "light gray"),
|
("background", "black", "light gray"),
|
||||||
("hotkey", "black,underline", "light gray", "underline"),
|
("hotkey", add_setting("black", "underline"), "light gray", "underline"),
|
||||||
("focused sidebar", "yellow", "dark gray", "standout"),
|
("focused sidebar", "yellow", "light gray", "standout"),
|
||||||
|
|
||||||
("warning", "white,bold", "dark red", "standout"),
|
("warning", add_setting("white", "bold"), "dark red", "standout"),
|
||||||
|
|
||||||
("label", "black", "light gray"),
|
("label", "black", "light gray"),
|
||||||
("value", "black", "dark cyan"),
|
("value", "black", "dark cyan"),
|
||||||
("fixed value", "dark gray", "dark cyan"),
|
("fixed value", "dark gray", "dark cyan"),
|
||||||
|
|
||||||
("dialog title", "white, bold", "dark cyan"),
|
("dialog title", add_setting("white", "bold"), "dark cyan"),
|
||||||
|
|
||||||
# highlighting
|
# highlighting
|
||||||
("source", "yellow", "dark blue"),
|
("source", "yellow", "dark blue"),
|
||||||
@ -738,11 +771,12 @@ class DebuggerUI(object):
|
|||||||
("current source", "black", "dark cyan"),
|
("current source", "black", "dark cyan"),
|
||||||
("current focused source", "white", "dark cyan"),
|
("current focused source", "white", "dark cyan"),
|
||||||
|
|
||||||
("keyword", "white,bold", "dark blue"),
|
("keyword", add_setting("white", "bold"), "dark blue"),
|
||||||
("literal", "light magenta", "dark blue"),
|
("literal", "light magenta", "dark blue"),
|
||||||
("punctuation", "light gray", "dark blue"),
|
("punctuation", "light gray", "dark blue"),
|
||||||
("comment", "light gray", "dark blue"),
|
("comment", "light gray", "dark blue"),
|
||||||
])
|
]
|
||||||
|
screen.register_palette(palette)
|
||||||
|
|
||||||
# UI enter/exit -----------------------------------------------------------
|
# UI enter/exit -----------------------------------------------------------
|
||||||
def show(self):
|
def show(self):
|
||||||
@ -874,13 +908,19 @@ class DebuggerUI(object):
|
|||||||
def set_current_file(self, fname):
|
def set_current_file(self, fname):
|
||||||
if self.shown_file != fname:
|
if self.shown_file != fname:
|
||||||
try:
|
try:
|
||||||
inf = open(fname)
|
inf = open(fname, "r")
|
||||||
except IOError:
|
|
||||||
self.source[:] = [SourceLine(self, fname)]
|
|
||||||
else:
|
|
||||||
self.source[:] = self.format_source(inf.readlines())
|
self.source[:] = self.format_source(inf.readlines())
|
||||||
self.shown_file = fname
|
inf.close()
|
||||||
|
except:
|
||||||
|
from traceback import format_exception
|
||||||
|
import sys
|
||||||
|
|
||||||
|
self.message("Trouble loading '%s':\n\n%s" % (
|
||||||
|
fname, "".join(format_exception(*sys.exc_info()))))
|
||||||
|
self.source[:] = [SourceLine(self,
|
||||||
|
"Error while loading '%s'." % fname)]
|
||||||
|
|
||||||
|
self.shown_file = fname
|
||||||
self.current_line = None
|
self.current_line = None
|
||||||
|
|
||||||
def set_current_line(self, fname, line):
|
def set_current_line(self, fname, line):
|
||||||
|
54
setup.py
54
setup.py
@ -9,12 +9,62 @@ from setuptools import setup
|
|||||||
setup(name='pudb',
|
setup(name='pudb',
|
||||||
version='0.90',
|
version='0.90',
|
||||||
description='Python Urwid debugger',
|
description='Python Urwid debugger',
|
||||||
|
long_description="""
|
||||||
|
PuDB is a visual debugger for Python. It runs in the same terminal
|
||||||
|
where you run your code. Installing it is as easy as::
|
||||||
|
|
||||||
|
easy_install pudb
|
||||||
|
|
||||||
|
Features
|
||||||
|
--------
|
||||||
|
|
||||||
|
Why would you want to use pudb?
|
||||||
|
|
||||||
|
* Syntax Highlighting
|
||||||
|
* Better code awareness than line-based `pdb`
|
||||||
|
* Use only a single keystroke for most commands
|
||||||
|
* Self-documenting
|
||||||
|
* Set breakpoints visually
|
||||||
|
* Easy access to a Python shell
|
||||||
|
|
||||||
|
Getting Started
|
||||||
|
---------------
|
||||||
|
|
||||||
|
To start debugging, simply insert::
|
||||||
|
|
||||||
|
from pudb import set_trace; set_trace()
|
||||||
|
|
||||||
|
into the piece of code you want to debug, or run the entire script with::
|
||||||
|
|
||||||
|
python -m pudb my-script.py
|
||||||
|
|
||||||
|
It is almost as lightweight as Python's included debugger, `pdb`.
|
||||||
|
""",
|
||||||
author='Andreas Kloeckner',
|
author='Andreas Kloeckner',
|
||||||
author_email='inform@tiker.net',
|
author_email='inform@tiker.net',
|
||||||
requires=[
|
setup_requires=[
|
||||||
"urwid>=0.9.8.4",
|
"urwid>=0.9.8.4",
|
||||||
"pygments>=1.0",
|
"pygments>=1.0",
|
||||||
],
|
],
|
||||||
url='http://pypi.python.org/pypi/pudb',
|
url='http://pypi.python.org/pypi/pudb',
|
||||||
py_modules="pudb")
|
classifiers=[
|
||||||
|
"Development Status :: 4 - Beta",
|
||||||
|
"Environment :: Console",
|
||||||
|
"Environment :: Console :: Curses",
|
||||||
|
"Intended Audience :: Developers",
|
||||||
|
"License :: OSI Approved :: MIT License",
|
||||||
|
"Natural Language :: English",
|
||||||
|
"Operating System :: POSIX",
|
||||||
|
"Operating System :: Unix",
|
||||||
|
"Programming Language :: Python",
|
||||||
|
"Programming Language :: Python :: 2",
|
||||||
|
"Topic :: Software Development",
|
||||||
|
"Topic :: Software Development :: Debuggers",
|
||||||
|
"Topic :: Software Development :: Quality Assurance",
|
||||||
|
"Topic :: System :: Recovery Tools",
|
||||||
|
"Topic :: System :: Software Distribution",
|
||||||
|
"Topic :: Terminals",
|
||||||
|
"Topic :: Utilities",
|
||||||
|
],
|
||||||
|
py_modules=["pudb"])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user