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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
642b09e7
Commit
642b09e7
authored
Mar 28, 2016
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor code cleanup
parent
f0c18bf1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
Cython/Compiler/Options.py
Cython/Compiler/Options.py
+17
-8
No files found.
Cython/Compiler/Options.py
View file @
642b09e7
...
@@ -263,6 +263,7 @@ directive_scopes = { # defaults to available everywhere
...
@@ -263,6 +263,7 @@ directive_scopes = { # defaults to available everywhere
'language_level'
:
(
'module'
,),
'language_level'
:
(
'module'
,),
}
}
def
parse_directive_value
(
name
,
value
,
relaxed_bool
=
False
):
def
parse_directive_value
(
name
,
value
,
relaxed_bool
=
False
):
"""
"""
Parses value as an option value for the given name and returns
Parses value as an option value for the given name and returns
...
@@ -292,16 +293,21 @@ def parse_directive_value(name, value, relaxed_bool=False):
...
@@ -292,16 +293,21 @@ def parse_directive_value(name, value, relaxed_bool=False):
ValueError: c_string_type directive must be one of ('bytes', 'bytearray', 'str', 'unicode'), got 'unnicode'
ValueError: c_string_type directive must be one of ('bytes', 'bytearray', 'str', 'unicode'), got 'unnicode'
"""
"""
type
=
directive_types
.
get
(
name
)
type
=
directive_types
.
get
(
name
)
if
not
type
:
return
None
if
not
type
:
return
None
orig_value
=
value
orig_value
=
value
if
type
is
bool
:
if
type
is
bool
:
value
=
str
(
value
)
value
=
str
(
value
)
if
value
==
'True'
:
return
True
if
value
==
'True'
:
if
value
==
'False'
:
return
False
return
True
if
value
==
'False'
:
return
False
if
relaxed_bool
:
if
relaxed_bool
:
value
=
value
.
lower
()
value
=
value
.
lower
()
if
value
in
(
"true"
,
"yes"
):
return
True
if
value
in
(
"true"
,
"yes"
):
elif
value
in
(
"false"
,
"no"
):
return
False
return
True
elif
value
in
(
"false"
,
"no"
):
return
False
raise
ValueError
(
"%s directive must be set to True or False, got '%s'"
%
(
raise
ValueError
(
"%s directive must be set to True or False, got '%s'"
%
(
name
,
orig_value
))
name
,
orig_value
))
elif
type
is
int
:
elif
type
is
int
:
...
@@ -317,6 +323,7 @@ def parse_directive_value(name, value, relaxed_bool=False):
...
@@ -317,6 +323,7 @@ def parse_directive_value(name, value, relaxed_bool=False):
else
:
else
:
assert
False
assert
False
def
parse_directive_list
(
s
,
relaxed_bool
=
False
,
ignore_unknown
=
False
,
def
parse_directive_list
(
s
,
relaxed_bool
=
False
,
ignore_unknown
=
False
,
current_settings
=
None
):
current_settings
=
None
):
"""
"""
...
@@ -352,9 +359,11 @@ def parse_directive_list(s, relaxed_bool=False, ignore_unknown=False,
...
@@ -352,9 +359,11 @@ def parse_directive_list(s, relaxed_bool=False, ignore_unknown=False,
result
=
current_settings
result
=
current_settings
for
item
in
s
.
split
(
','
):
for
item
in
s
.
split
(
','
):
item
=
item
.
strip
()
item
=
item
.
strip
()
if
not
item
:
continue
if
not
item
:
if
not
'='
in
item
:
raise
ValueError
(
'Expected "=" in option "%s"'
%
item
)
continue
name
,
value
=
[
s
.
strip
()
for
s
in
item
.
strip
().
split
(
'='
,
1
)
]
if
not
'='
in
item
:
raise
ValueError
(
'Expected "=" in option "%s"'
%
item
)
name
,
value
=
[
s
.
strip
()
for
s
in
item
.
strip
().
split
(
'='
,
1
)]
if
name
not
in
directive_defaults
:
if
name
not
in
directive_defaults
:
found
=
False
found
=
False
if
name
.
endswith
(
'.all'
):
if
name
.
endswith
(
'.all'
):
...
...
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