summaryrefslogtreecommitdiff
path: root/Lib/packaging/create.py
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-11-06 11:32:47 +0100
committerÉric Araujo <merwok@netwok.org>2011-11-06 11:32:47 +0100
commitfad46e19b4e6b2173b84e6216465e6fe5824ba2a (patch)
tree5fc4bb7de10764e1f7276072681892d65ea6d9e1 /Lib/packaging/create.py
parent261ccdce4825535d4f6ea4bf09e9394bb751df20 (diff)
downloadcpython-git-fad46e19b4e6b2173b84e6216465e6fe5824ba2a.tar.gz
Clean up mocking of stdout and stdin in packaging tests.
Running with regrtest does not show spurious output or unrestored sys.std* objects; sometimes running with make test is different, I’ll watch the buildbots. In addition, update the create module to use logging.
Diffstat (limited to 'Lib/packaging/create.py')
-rw-r--r--Lib/packaging/create.py29
1 files changed, 14 insertions, 15 deletions
diff --git a/Lib/packaging/create.py b/Lib/packaging/create.py
index 59b448dc62..de05ac8a19 100644
--- a/Lib/packaging/create.py
+++ b/Lib/packaging/create.py
@@ -30,6 +30,7 @@ from textwrap import dedent
from tokenize import detect_encoding
from configparser import RawConfigParser
+from packaging import logger
# importing this with an underscore as it should be replaced by the
# dict form or another structures for all purposes
from packaging._trove import all_classifiers as _CLASSIFIERS_LIST
@@ -124,7 +125,7 @@ def ask_yn(question, default=None, helptext=None):
if answer and answer[0].lower() in ('y', 'n'):
return answer[0].lower()
- print('\nERROR: You must select "Y" or "N".\n')
+ logger.error('You must select "Y" or "N".')
# XXX use util.ask
@@ -147,10 +148,7 @@ def ask(question, default=None, helptext=None, required=True,
helptext = helptext.strip("\n")
while True:
- sys.stdout.write(prompt)
- sys.stdout.flush()
-
- line = sys.stdin.readline().strip()
+ line = input(prompt).strip()
if line == '?':
print('=' * 70)
print(helptext)
@@ -271,9 +269,10 @@ class MainProgram:
def _write_cfg(self):
if os.path.exists(_FILENAME):
if os.path.exists('%s.old' % _FILENAME):
- print("ERROR: %(name)s.old backup exists, please check that "
- "current %(name)s is correct and remove %(name)s.old" %
- {'name': _FILENAME})
+ message = ("ERROR: %(name)s.old backup exists, please check "
+ "that current %(name)s is correct and remove "
+ "%(name)s.old" % {'name': _FILENAME})
+ logger.error(message)
return
shutil.move(_FILENAME, '%s.old' % _FILENAME)
@@ -320,7 +319,7 @@ class MainProgram:
fp.write('\n')
os.chmod(_FILENAME, 0o644)
- print('Wrote "%s".' % _FILENAME)
+ logger.info('Wrote "%s".' % _FILENAME)
def convert_py_to_cfg(self):
"""Generate a setup.cfg from an existing setup.py.
@@ -614,8 +613,8 @@ class MainProgram:
break
if len(found_list) == 0:
- print('ERROR: Could not find a matching license for "%s"' %
- license)
+ logger.error('Could not find a matching license for "%s"' %
+ license)
continue
question = 'Matching licenses:\n\n'
@@ -636,8 +635,8 @@ class MainProgram:
try:
index = found_list[int(choice) - 1]
except ValueError:
- print("ERROR: Invalid selection, type a number from the list "
- "above.")
+ logger.error(
+ "Invalid selection, type a number from the list above.")
classifiers.add(_CLASSIFIERS_LIST[index])
@@ -660,8 +659,8 @@ class MainProgram:
classifiers.add(key)
return
except (IndexError, ValueError):
- print("ERROR: Invalid selection, type a single digit "
- "number.")
+ logger.error(
+ "Invalid selection, type a single digit number.")
def main():