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
10b03f63
Commit
10b03f63
authored
Nov 13, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove an unnecessary dependency on "glob" from Code.py, minor cleanups
parent
bdcf0f26
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
19 deletions
+14
-19
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+14
-19
No files found.
Cython/Compiler/Code.py
View file @
10b03f63
...
@@ -11,7 +11,6 @@ cython.declare(re=object, Naming=object, Options=object, StringEncoding=object,
...
@@ -11,7 +11,6 @@ cython.declare(re=object, Naming=object, Options=object, StringEncoding=object,
import
os
import
os
import
re
import
re
import
glob
import
Naming
import
Naming
import
Options
import
Options
import
StringEncoding
import
StringEncoding
...
@@ -52,7 +51,7 @@ class UtilityCodeBase(object):
...
@@ -52,7 +51,7 @@ class UtilityCodeBase(object):
_utility_cache
=
{}
_utility_cache
=
{}
#
@classmethod
@
classmethod
def
_add_utility
(
cls
,
utility
,
type
,
lines
,
begin_lineno
):
def
_add_utility
(
cls
,
utility
,
type
,
lines
,
begin_lineno
):
if
utility
:
if
utility
:
# Remember line numbers as least until after templating
# Remember line numbers as least until after templating
...
@@ -63,9 +62,7 @@ class UtilityCodeBase(object):
...
@@ -63,9 +62,7 @@ class UtilityCodeBase(object):
else
:
else
:
utility
[
1
]
=
code
utility
[
1
]
=
code
_add_utility
=
classmethod
(
_add_utility
)
@
classmethod
# @classmethod
def
load_utilities_from_file
(
cls
,
path
):
def
load_utilities_from_file
(
cls
,
path
):
utilities
=
cls
.
_utility_cache
.
get
(
path
)
utilities
=
cls
.
_utility_cache
.
get
(
path
)
if
utilities
:
if
utilities
:
...
@@ -123,9 +120,7 @@ class UtilityCodeBase(object):
...
@@ -123,9 +120,7 @@ class UtilityCodeBase(object):
cls
.
_utility_cache
[
path
]
=
utilities
cls
.
_utility_cache
[
path
]
=
utilities
return
utilities
return
utilities
load_utilities_from_file
=
classmethod
(
load_utilities_from_file
)
@
classmethod
# @classmethod
def
load
(
cls
,
util_code_name
,
from_file
=
None
,
context
=
None
,
**
kwargs
):
def
load
(
cls
,
util_code_name
,
from_file
=
None
,
context
=
None
,
**
kwargs
):
"""
"""
Load a utility code from a file specified by from_file (relative to
Load a utility code from a file specified by from_file (relative to
...
@@ -165,20 +160,22 @@ class UtilityCodeBase(object):
...
@@ -165,20 +160,22 @@ class UtilityCodeBase(object):
return
cls
(
**
kwargs
)
return
cls
(
**
kwargs
)
load
=
classmethod
(
load
)
@
classmethod
# @classmethod
def
load_as_string
(
cls
,
util_code_name
,
from_file
=
None
,
context
=
None
):
def
load_as_string
(
cls
,
util_code_name
,
from_file
=
None
,
context
=
None
):
"""
"""
Load a utility code as a string. Returns (proto, implementation)
Load a utility code as a string. Returns (proto, implementation)
"""
"""
if
from_file
is
None
:
if
from_file
is
None
:
files
=
glob
.
glob
(
os
.
path
.
join
(
get_utility_dir
(),
utility_dir
=
get_utility_dir
()
util_code_name
+
'.*'
))
prefix
=
util_code_name
+
'.'
if
len
(
files
)
!=
1
:
files
=
[
os
.
path
.
join
(
utility_dir
,
filename
)
raise
ValueError
(
"Need exactly one utility file"
)
for
filename
in
os
.
listdir
(
utility_dir
)
if
filename
.
startswith
(
prefix
)
]
from_file
,
=
files
if
not
files
:
raise
ValueError
(
"No match found for utility code "
+
util_code_name
)
if
len
(
files
)
>
1
:
raise
ValueError
(
"More than one filename match found for utility code "
+
util_code_name
)
from_file
=
files
[
0
]
utilities
=
cls
.
load_utilities_from_file
(
from_file
)
utilities
=
cls
.
load_utilities_from_file
(
from_file
)
...
@@ -193,8 +190,6 @@ class UtilityCodeBase(object):
...
@@ -193,8 +190,6 @@ class UtilityCodeBase(object):
return
proto
and
proto
.
lstrip
(),
impl
and
impl
.
lstrip
()
return
proto
and
proto
.
lstrip
(),
impl
and
impl
.
lstrip
()
load_as_string
=
classmethod
(
load_as_string
)
def
none_or_sub
(
self
,
s
,
context
,
tempita
):
def
none_or_sub
(
self
,
s
,
context
,
tempita
):
"""
"""
Format a string in this utility code with context. If None, do nothing.
Format a string in this utility code with context. If None, do nothing.
...
...
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