Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
54015fbb
Commit
54015fbb
authored
Feb 13, 1996
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
even better way to normalize spaces in add_flowing_data
parent
8c0ea4b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
17 deletions
+9
-17
Lib/formatter.py
Lib/formatter.py
+9
-17
No files found.
Lib/formatter.py
View file @
54015fbb
...
...
@@ -110,26 +110,18 @@ class AbstractFormatter:
if
not
data
:
return
# The following looks a bit convoluted but is a great improvement over
# data = regsub.gsub('[' + string.whitespace + ']+', ' ', data)
if
data
[
0
]
in
string
.
whitespace
:
head
=
' '
else
:
head
=
''
if
data
[
-
1
]
in
string
.
whitespace
:
tail
=
' '
else
:
tail
=
''
data
=
head
+
string
.
join
(
string
.
split
(
data
))
if
data
!=
' '
:
data
=
data
+
tail
#
if
self
.
nospace
and
data
[
0
]
==
' '
:
data
=
data
[
1
:]
prespace
=
data
[
0
]
in
string
.
whitespace
postspace
=
data
[
-
1
]
in
string
.
whitespace
data
=
string
.
join
(
string
.
split
(
data
))
if
self
.
nospace
and
prespace
:
if
not
data
:
return
elif
self
.
softspace
and
data
[
0
]
!=
' '
:
data
=
' '
+
data
prespace
=
0
elif
self
.
softspace
:
prespace
=
1
self
.
nospace
=
self
.
softspace
=
0
if
data
[
-
1
]
==
' '
:
data
=
data
[:
-
1
]
if
postspace
:
self
.
softspace
=
1
if
prespace
:
data
=
' '
+
data
self
.
writer
.
send_flowing_data
(
data
)
def
add_literal_data
(
self
,
data
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment