Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
c65bc875
Commit
c65bc875
authored
Jul 27, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reformat code
parent
a7c82988
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
32 deletions
+35
-32
Cython/Utils.py
Cython/Utils.py
+35
-32
No files found.
Cython/Utils.py
View file @
c65bc875
...
...
@@ -217,42 +217,45 @@ def detect_opened_file_encoding(f):
normalise_newlines
=
re
.
compile
(
u'
\
r
\
n
?|
\
n
'
).
sub
class
NormalisedNewlineStream
(
object
):
"""The codecs module doesn't provide universal newline support.
This class is used as a stream wrapper that provides this
functionality. The new 'io' in Py2.6+/3.x supports this out of the
box.
"""
def
__init__
(
self
,
stream
):
# let's assume .read() doesn't change
self
.
stream
=
stream
self
.
_read
=
stream
.
read
self
.
close
=
stream
.
close
self
.
encoding
=
getattr
(
stream
,
'encoding'
,
'UTF-8'
)
def
read
(
self
,
count
=-
1
):
data
=
self
.
_read
(
count
)
if
u'
\
r
'
not
in
data
:
return
data
if
data
.
endswith
(
u'
\
r
'
):
# may be missing a '\n'
data
+=
self
.
_read
(
1
)
return
normalise_newlines
(
u'
\
n
'
,
data
)
def
readlines
(
self
):
content
=
[]
data
=
self
.
read
(
0x1000
)
while
data
:
content
.
append
(
data
)
"""The codecs module doesn't provide universal newline support.
This class is used as a stream wrapper that provides this
functionality. The new 'io' in Py2.6+/3.x supports this out of the
box.
"""
def
__init__
(
self
,
stream
):
# let's assume .read() doesn't change
self
.
stream
=
stream
self
.
_read
=
stream
.
read
self
.
close
=
stream
.
close
self
.
encoding
=
getattr
(
stream
,
'encoding'
,
'UTF-8'
)
def
read
(
self
,
count
=-
1
):
data
=
self
.
_read
(
count
)
if
u'
\
r
'
not
in
data
:
return
data
if
data
.
endswith
(
u'
\
r
'
):
# may be missing a '\n'
data
+=
self
.
_read
(
1
)
return
normalise_newlines
(
u'
\
n
'
,
data
)
def
readlines
(
self
):
content
=
[]
data
=
self
.
read
(
0x1000
)
while
data
:
content
.
append
(
data
)
data
=
self
.
read
(
0x1000
)
return
u''
.
join
(
content
).
splitlines
(
True
)
return
u''
.
join
(
content
).
splitlines
(
True
)
def
seek
(
self
,
pos
):
if
pos
==
0
:
self
.
stream
.
seek
(
0
)
else
:
raise
NotImplementedError
def
seek
(
self
,
pos
):
if
pos
==
0
:
self
.
stream
.
seek
(
0
)
else
:
raise
NotImplementedError
io
=
None
if
sys
.
version_info
>=
(
2
,
6
):
...
...
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