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
65ea99f4
Commit
65ea99f4
authored
Feb 26, 2013
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
multiple-choice directive type
parent
85ee8e60
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
0 deletions
+12
-0
Cython/Compiler/Options.py
Cython/Compiler/Options.py
+12
-0
No files found.
Cython/Compiler/Options.py
View file @
65ea99f4
...
...
@@ -135,6 +135,15 @@ extra_warnings = {
'warn.unused'
:
True
,
}
def
one_of
(
*
args
):
def
validate
(
name
,
value
):
if
value
not
in
args
:
raise
ValueError
(
"%s directive must be one of %s, got '%s'"
%
(
name
,
args
,
value
))
else
:
return
value
return
validate
# Override types possibilities above, if needed
directive_types
=
{
'final'
:
bool
,
# final cdef classes and methods
...
...
@@ -146,6 +155,7 @@ directive_types = {
'cclass'
:
None
,
'returns'
:
type
,
'set_initial_path'
:
str
,
'c_string_type'
:
one_of
(
'bytes'
,
'str'
,
'unicoode'
),
}
for
key
,
val
in
directive_defaults
.
items
():
...
...
@@ -203,6 +213,8 @@ def parse_directive_value(name, value, relaxed_bool=False):
name
,
orig_value
))
elif
type
is
str
:
return
str
(
value
)
elif
callable
(
type
):
return
type
(
name
,
value
)
else
:
assert
False
...
...
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