diff options
| author | Éric Araujo <merwok@netwok.org> | 2011-05-31 16:04:32 (GMT) |
|---|---|---|
| committer | Éric Araujo <merwok@netwok.org> | 2011-05-31 16:04:32 (GMT) |
| commit | 9deedf696eeb9a015118d1d0c76bf8318f2190d2 (patch) | |
| tree | 8ae467a6de6102b27017c02972bf538230511d44 /Lib/packaging/fancy_getopt.py | |
| parent | a94bdee2e479cdfa6b98c7d823380a88dcb8c9fd (diff) | |
| download | cpython-9deedf696eeb9a015118d1d0c76bf8318f2190d2.zip cpython-9deedf696eeb9a015118d1d0c76bf8318f2190d2.tar.gz cpython-9deedf696eeb9a015118d1d0c76bf8318f2190d2.tar.bz2 | |
Re-apply distutils2 changes lost before the merge of packaging.
wrap_text was removed in favor of standard textwrap but the removal of the
function was lost in a bad merge; a change in sdist mysteriously disappeared.
Diffstat (limited to 'Lib/packaging/fancy_getopt.py')
| -rw-r--r-- | Lib/packaging/fancy_getopt.py | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/Lib/packaging/fancy_getopt.py b/Lib/packaging/fancy_getopt.py index ebe376e..61dd5fc 100644 --- a/Lib/packaging/fancy_getopt.py +++ b/Lib/packaging/fancy_getopt.py @@ -13,7 +13,6 @@ It is used under the hood by the command classes. Do not use directly. import getopt import re import sys -import string import textwrap from packaging.errors import PackagingGetoptError, PackagingArgError @@ -378,68 +377,6 @@ def fancy_getopt(options, negative_opt, object, args): return parser.getopt(args, object) -WS_TRANS = str.maketrans(string.whitespace, ' ' * len(string.whitespace)) - - -def wrap_text(text, width): - """Split *text* into lines of no more than *width* characters each. - - *text* is a str and *width* an int. Returns a list of str. - """ - - if text is None: - return [] - if len(text) <= width: - return [text] - - text = text.expandtabs() - text = text.translate(WS_TRANS) - - chunks = re.split(r'( +|-+)', text) - chunks = [_f for _f in chunks if _f] # ' - ' results in empty strings - lines = [] - - while chunks: - - cur_line = [] # list of chunks (to-be-joined) - cur_len = 0 # length of current line - - while chunks: - l = len(chunks[0]) - if cur_len + l <= width: # can squeeze (at least) this chunk in - cur_line.append(chunks[0]) - del chunks[0] - cur_len = cur_len + l - else: # this line is full - # drop last chunk if all space - if cur_line and cur_line[-1][0] == ' ': - del cur_line[-1] - break - - if chunks: # any chunks left to process? - - # if the current line is still empty, then we had a single - # chunk that's too big too fit on a line -- so we break - # down and break it up at the line width - if cur_len == 0: - cur_line.append(chunks[0][0:width]) - chunks[0] = chunks[0][width:] - - # all-whitespace chunks at the end of a line can be discarded - # (and we know from the re.split above that if a chunk has - # *any* whitespace, it is *all* whitespace) - if chunks[0][0] == ' ': - del chunks[0] - - # and store this line in the list-of-all-lines -- as a single - # string, of course! - lines.append(''.join(cur_line)) - - # while chunks - - return lines - - class OptionDummy: """Dummy class just used as a place to hold command-line option values as instance attributes.""" |
