Permalink
Browse files

Merge branch 'release/1.0.0'

  • Loading branch information...
1 parent 4f8a33e commit 928919070728e9c9d2115742ab12d332cfb544e1 @kennethreitz committed Sep 5, 2010
Showing with 153 additions and 150 deletions.
  1. +18 −6 .gitignore
  2. +13 −0 AUTHORS
  3. +8 −2 HISTORY.rst
  4. +11 −0 MANIFEST.in
  5. +12 −0 NOTICE
  6. +1 −7 README.rst
  7. +7 −0 ROADMAP.rst
  8. +1 −0 reqs.txt
  9. +2 −2 setup.py
  10. +2 −1 showme/__init__.py
  11. +51 −34 showme/core.py
  12. +14 −0 showme/tests/test_cputime.py
  13. +2 −4 showme/tests/test_docs.py
  14. +0 −55 showme/tests/test_globals.py
  15. +0 −23 showme/tests/test_locals.py
  16. +11 −1 showme/tests/test_trace.py
  17. +0 −15 test.py
View
@@ -1,6 +1,18 @@
-.idea/encodings.xml
-.idea/misc.xml
-.idea/modules.xml
-.idea/showme.iml
-.idea/vcs.xml
-.idea/workspace.xml
+# parser's output files
+output/*
+
+# application builds
+build/*
+dist/*
+
+# python skin
+.pyc
+.pyo
+
+# osx noise
+.DS_Store
+profile
+
+# pycharm noise
+.idea
+.idea/*
View
13 AUTHORS
@@ -0,0 +1,13 @@
+showme is written and maintained by Kenneth Reitz and
+various contributors:
+
+Development Lead
+````````````````
+
+- Kenneth Reitz <me@kennethreitz.com>
+
+
+Patches and Suggestions
+```````````````````````
+
+- A Lucky Someone
View
@@ -3,19 +3,25 @@ History
1.0.0 (2010-09-05)
------------------
-* Basic feature-set mostly complete
+* Featureset complete
* Public release of showme to PyPi
+* Cleanup of project (removal of globals/locals)
+
0.0.5 (2010-09-05)
------------------
+* @showme.time support (simple but big feature)
* Color output added (via vendorized Colorama)
+
0.0.4 (2010-09-04)
------------------
* Epic @showme.trace decorator written
* @showme.docs support
+
0.0.3 (2010-09-01)
------------------
* General configuration in place
-*
+* @showme.cputime support
+* Vendorization of decorator decorator
View
@@ -0,0 +1,11 @@
+include AUTHORS
+include HISTORY.rst
+include README.rst
+include ROADMAP.rst
+include LICENSE
+include NOTICE
+include reqs.txt
+
+recursive-include *.py
+recursive-include showme *
+recursive-include showme/packages *
View
12 NOTICE
@@ -0,0 +1,12 @@
+DECORATOR LICENSE (packaged module)
+===================================
+
+Copyright (c) 2010, Michele Simionato
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+Neither the name of the Michele Simionato nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
View
@@ -20,7 +20,7 @@ Print passed-in arguments and function calls. ::
Print function execution time. ::
- @showme.time
+ @showme.cputime
def complex_function(a, b, c):…
>>> complex_function()
@@ -32,12 +32,6 @@ Print function execution time. ::
1 0.000 0.000 0.000 0.000 {range}
-Print global variables available at runtime. ::
-
- @showme.globals
- def complex_function(a, b, c):…
-
-
Print local variables available at runtime. ::
@showme.locals
View
@@ -0,0 +1,7 @@
+Roadmap
+=======
+
+Key features
+------------
+
+- Add ``@showme.locals``, once I figure that out.
View
@@ -0,0 +1 @@
+# That's right. None. Enjoy.
View
@@ -16,13 +16,13 @@ def publish():
sys.exit()
setup(name='showme',
- version=showmes.core.__version__,
+ version=showme.core.__version__,
description='Painless Debugging and Inspection for Python',
long_description=open('README.rst').read() + '\n\n' + open('HISTORY.rst').read(),
author='Kenneth Reitz',
author_email='me@kennethreitz.com',
url='http://github.com/kennethreitz/showme',
- packages=['showmes'],
+ packages=['showme'],
license='MIT',
classifiers = (
"Development Status :: 4 - Beta",
View
@@ -1 +1,2 @@
-from core import *
+from core import *
+import tests
View
@@ -1,76 +1,93 @@
-# ______
-# ___________ /_ ______ ___ _________ ___ _____
+# ______
+# ___________ /_ ______ ___ _________ ___ _____
# __ ___/__ __ \_ __ \__ | /| / /__ __ `__ \_ _ \
# _(__ ) _ / / // /_/ /__ |/ |/ / _ / / / / // __/
-# /____/ /_/ /_/ \____/ ____/|__/ /_/ /_/ /_/ \___/
+# /____/ /_/ /_/ \____/ ____/|__/ /_/ /_/ /_/ \___/
+from showme.packages.colorama import *
from showme.packages.decorator import decorator
import cProfile
import inspect
-import pprint
+from time import time as now
-__version__ = '0.0.4'
+
+__version__ = '1.0.0'
__author__ = 'Kenneth Reitz'
__license__ = 'MIT'
__copyright__ = 'Copyright 2010 Kenneth Reitz'
+__all__ = ('cputime', 'docs', 'time', 'trace')
+
-pp = pprint.PrettyPrinter(indent=4)
+# CLI Color
+init(autoreset=True)
@decorator
-def time(f, *args, **kwargs):
- """Display CPU Time statistics of given function"""
+def cputime(f, *args, **kwargs):
+ """Display CPU Time statistics of given function."""
+
+ print('CPU time for %s%s%s:' % (Fore.CYAN, _get_scope(f, args), Fore.RESET))
t = cProfile.Profile()
r = t.runcall(f, *args, **kwargs)
t.print_stats()
-
+
return r
-
+
@decorator
-def globals(f, *args, **kwargs):
- """Display global variables"""
+def docs(f, *args, **kwargs):
+ """Display Docstrings of given function."""
+
+ print('Documentation for %s%s%s:' % (Fore.CYAN, _get_scope(f, args), Fore.RESET))
+ print(inspect.getdoc(f))
- print('Globals:')
- print globals()
return f(*args, **kwargs)
@decorator
-def locals(f, *args, **kwargs):
- """Display local variables"""
- # print locals()
- return f(*args, **kwargs)
+def time(f, *args, **kwargs):
+ """Display Runtime statistics of given function."""
+ print('Execution speed of %s%s%s:' % (Fore.CYAN, _get_scope(f, args), Fore.RESET))
+ _t0 = now()
+ _r = f(*args, **kwargs)
+ _t1 = now()
-@decorator
-def docs(f, *args, **kwargs):
- """Display PyDocs of given function"""
- print inspect.getdoc(f)
- return f(*args, **kwargs)
+ total_time = _t1-_t0
+ print('%s seconds' % (total_time))
+
+ return _r
@decorator
def trace(f, *args, **kwargs):
- """Print scope, call, and argument information."""
+ """Display epic argument and context call information of given function."""
- _scope = inspect.getmodule(f).__name__
-
- # guess that function is a method of it's class
- if f.func_name in dir(args[0].__class__):
- _scope += '.' + args[0].__class__.__name__
- _scope += '.' + f.__name__
- else:
- _scope += '.' + f.__name__
-
+ _scope = _get_scope(f, args)
- print("calling %s() with \nargs: %s \nkwargs: %s" % (_scope, args, kwargs))
+ print("Calling %s%s%s with: \n %sargs%s: %s \n %skwargs%s: %s" % (
+ Fore.CYAN, _scope, Fore.RESET, Fore.BLUE, Fore.RESET,
+ args, Fore.BLUE, Fore.RESET, kwargs))
return f(*args, **kwargs)
+def _get_scope(f, args):
+ """Get scope nameo of given function."""
+ _scope = inspect.getmodule(f).__name__
+ # guess that function is a method of it's class
+ try:
+ if f.func_name in dir(args[0].__class__):
+ _scope += '.' + args[0].__class__.__name__
+ _scope += '.' + f.__name__
+ else:
+ _scope += '.' + f.__name__
+ except IndexError:
+ _scope += '.' + f.__name__
+
+ return _scope
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import showme
+
+@showme.cputime
+def test():
+ """docstring for test"""
+ for i in range(1000):
+ a = i ** i
+ return 1
+
+if __name__ == '__main__':
+ test()
@@ -15,9 +15,7 @@
@showme.docs
def test():
"""sample docstring for test"""
- for i in range(1000):
- a = i ** i
+ pass
if __name__ == '__main__':
- import doctest
- doctest.testmod()
+ test()
@@ -1,55 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-"""
-
->>> test()
-sample docstring for test
-
-"""
-
-# import doctest
-# import showme
-import sys
-#
-# @showme.globals
-def test():
- """sample docstring for test"""
- # for i in range(1000):
- # a = i ** i
- face = 'hi'
- book = 'bye'
-#
-# if __name__ == '__main__':
-# import doctest
-# doctest.testmod()
-
-
-class persistent_locals2(object):
- def __init__(self, func):
- self._locals = {}
- self.func = func
-
- def __call__(self, *args, **kwargs):
- def tracer(frame, event, arg):
- if event=='return':
- self._locals = frame.f_locals.copy()
-
- # tracer is activated on next call, return or exception
- sys.setprofile(tracer)
- try:
- # trace the function call
- res = self.func(*args, **kwargs)
- finally:
- # disable tracer and replace with old one
- sys.setprofile(None)
- return res
-
- def clear_locals(self):
- self._locals = {}
-
- @property
- def locals(self):
- return self._locals
-
-print persistent_locals2(test)()
@@ -1,23 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-"""
-
->>> test()
-
-
-"""
-
-import doctest
-import showme
-
-
-@showme.locals
-def test():
- """sample docstring for test"""
- a = 'hi'
- b = 'bye'
-
-if __name__ == '__main__':
- import doctest
- doctest.testmod()
Oops, something went wrong.

0 comments on commit 9289190

Please sign in to comment.