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
31a16689
Commit
31a16689
authored
Jul 18, 2016
by
Tiago Peixoto
Browse files
Fix some Python 2 incompatibilities
parent
db22b670
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/graph_tool/__init__.py
View file @
31a16689
...
...
@@ -127,6 +127,13 @@ import csv
if
sys
.
version_info
<
(
3
,):
import
StringIO
def
_to_str
(
x
):
if
isinstance
(
x
,
unicode
):
return
x
.
encode
(
"utf8"
)
return
x
else
:
def
_to_str
(
x
):
return
x
from
.decorators
import
_wraps
,
_require
,
_attrs
,
_limit_args
,
_copy_func
from
inspect
import
ismethod
...
...
@@ -201,7 +208,7 @@ def _type_alias(type_name):
if
type_name
in
alias
:
return
alias
[
type_name
]
if
type_name
in
value_types
():
return
type_name
return
_to_str
(
type_name
)
ma
=
re
.
compile
(
r
"vector<(.*)>"
).
match
(
type_name
)
if
ma
:
t
=
ma
.
group
(
1
)
...
...
@@ -1308,7 +1315,7 @@ class InternalPropertyDict(dict):
self
.
__set_property
(
t
,
k
,
val
)
@
_limit_args
({
"t"
:
[
"v"
,
"e"
,
"g"
]})
@
_require
(
"key"
,
str
)
@
_require
(
"key"
,
str
,
unicode
)
def
__set_property
(
self
,
t
,
key
,
v
):
dict
.
__setitem__
(
self
,
(
t
,
key
),
v
)
...
...
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