Skip to content
Browse files

make display_status optional at runtime in setupext

This allow the check_for_readline to *not* print its indented status line
  • Loading branch information...
1 parent c85668c commit 21d05ca9cc332f1cfa4cac3693028489e7de8865 @minrk committed
Showing with 33 additions and 26 deletions.
  1. +4 −3 setup.py
  2. +29 −23 setupext/setupext.py
View
7 setup.py
@@ -62,7 +62,7 @@
check_for_dependencies,
record_commit_info,
)
-from setupext.setupext import check_for_readline
+from setupext import setupext
isfile = os.path.isfile
pjoin = os.path.join
@@ -220,9 +220,10 @@ def cleanup():
test='nose>=0.10.1',
)
requires = setup_args.setdefault('install_requires', [])
- if not check_for_readline():
+ setupext.display_status = False
+ if not setupext.check_for_readline():
if sys.platform == 'darwin':
- requires.append('readline')
+ requires.append('readline')
elif sys.platform.startswith('win'):
requires.append('pyreadline')
else:
View
52 setupext/setupext.py
@@ -18,29 +18,35 @@
display_status=True
-if display_status:
- def print_line(char='='):
- print char * 76
-
- def print_status(package, status):
- initial_indent = "%22s: " % package
- indent = ' ' * 24
- print fill(str(status), width=76,
- initial_indent=initial_indent,
- subsequent_indent=indent)
-
- def print_message(message):
- indent = ' ' * 24 + "* "
- print fill(str(message), width=76,
- initial_indent=indent,
- subsequent_indent=indent)
-
- def print_raw(section):
- print section
-else:
- def print_line(*args, **kwargs):
- pass
- print_status = print_message = print_raw = print_line
+def check_display(f):
+ """decorator to allow display methods to be muted by mod.display_status"""
+ def maybe_display(*args, **kwargs):
+ if display_status:
+ return f(*args, **kwargs)
+ return maybe_display
+
+@check_display
+def print_line(char='='):
+ print char * 76
+
+@check_display
+def print_status(package, status):
+ initial_indent = "%22s: " % package
+ indent = ' ' * 24
+ print fill(str(status), width=76,
+ initial_indent=initial_indent,
+ subsequent_indent=indent)
+
+@check_display
+def print_message(message):
+ indent = ' ' * 24 + "* "
+ print fill(str(message), width=76,
+ initial_indent=indent,
+ subsequent_indent=indent)
+
+@check_display
+def print_raw(section):
+ print section
#-------------------------------------------------------------------------------
# Tests for specific packages

0 comments on commit 21d05ca

Please sign in to comment.
Something went wrong with that request. Please try again.