Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tiago Peixoto
graph-tool
Commits
913d42f2
Commit
913d42f2
authored
Sep 16, 2015
by
Tiago Peixoto
Browse files
Fix compatibility issue with python 2
parent
857bdaac
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/graph_tool/__init__.py
View file @
913d42f2
...
...
@@ -2867,7 +2867,10 @@ for Vertex in libcore.get_vlist():
Vertex
.
all_neighbours
=
_all_neighbours
Vertex
.
in_degree
=
_in_degree
Vertex
.
out_degree
=
_out_degree
Vertex
.
is_valid
.
__doc__
=
"Returns ``True`` if the descriptor corresponds to an existing vertex in the graph, ``False`` otherwise."
try
:
Vertex
.
is_valid
.
__doc__
=
"Returns ``True`` if the descriptor corresponds to an existing vertex in the graph, ``False`` otherwise."
except
AttributeError
:
pass
Vertex
.
__repr__
=
_vertex_repr
Vertex
.
__eq__
=
v_eq
Vertex
.
__ne__
=
v_ne
...
...
@@ -2903,9 +2906,12 @@ for Edge in libcore.get_elist():
Edge
.
__repr__
=
_edge_repr
Edge
.
__iter__
=
_edge_iter
Edge
.
__doc__
=
_edge_doc
Edge
.
is_valid
.
__doc__
=
"Returns ``True`` if the descriptor corresponds to an existing edge in the graph, ``False`` otherwise."
Edge
.
source
.
__doc__
=
"Returns the source of the edge (a :class:`~graph_tool.Vertex` instance)."
Edge
.
target
.
__doc__
=
"Returns the target of the edge (a :class:`~graph_tool.Vertex` instance)."
try
:
Edge
.
is_valid
.
__doc__
=
"Returns ``True`` if the descriptor corresponds to an existing edge in the graph, ``False`` otherwise."
Edge
.
source
.
__doc__
=
"Returns the source of the edge (a :class:`~graph_tool.Vertex` instance)."
Edge
.
target
.
__doc__
=
"Returns the target of the edge (a :class:`~graph_tool.Vertex` instance)."
except
AttributeError
:
pass
# some shenanigans to make it seem there is only a single edge and vertex class
EdgeBase
.
__doc__
=
Edge
.
__doc__
...
...
src/graph_tool/collection/konect.py
View file @
913d42f2
...
...
@@ -25,7 +25,10 @@ if sys.version_info < (3,):
import
os.path
import
tempfile
import
urllib.request
if
sys
.
version_info
<
(
3
,):
from
urllib2
import
urlopen
else
:
from
urllib.request
import
urlopen
import
tarfile
import
warnings
import
numpy
...
...
@@ -77,13 +80,13 @@ def load_koblenz_dir(dirname):
def
get_koblenz_network_data
(
name
):
with
tempfile
.
TemporaryFile
(
mode
=
'w+b'
)
as
ftemp
:
with
urllib
.
request
.
urlopen
(
'http://konect.uni-koblenz.de/downloads/tsv/%s.tar.bz2'
%
name
)
as
response
:
buflen
=
1
<<
20
while
True
:
buf
=
response
.
read
(
buflen
)
ftemp
.
write
(
buf
)
if
len
(
buf
)
<
buflen
:
break
response
=
urlopen
(
'http://konect.uni-koblenz.de/downloads/tsv/%s.tar.bz2'
%
name
)
buflen
=
1
<<
20
while
True
:
buf
=
response
.
read
(
buflen
)
ftemp
.
write
(
buf
)
if
len
(
buf
)
<
buflen
:
break
ftemp
.
seek
(
0
)
with
tempfile
.
TemporaryDirectory
(
suffix
=
name
)
as
tempdir
:
with
tarfile
.
open
(
fileobj
=
ftemp
,
mode
=
'r:bz2'
)
as
tar
:
...
...
Write
Preview
Supports
Markdown
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