Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pystache_custom
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pystache_custom
Commits
78ef793b
Commit
78ef793b
authored
Jan 24, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added optional template_extension argument to Locator.make_file_name().
parent
3f119240
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
3 deletions
+20
-3
pystache/locator.py
+15
-3
tests/test_locator.py
+5
-0
No files found.
pystache/locator.py
View file @
78ef793b
...
...
@@ -76,10 +76,22 @@ class Locator(object):
return
re
.
sub
(
'[A-Z]'
,
repl
,
template_name
)[
1
:]
def
make_file_name
(
self
,
template_name
):
def
make_file_name
(
self
,
template_name
,
template_extension
=
None
):
"""
Generate and return the file name for the given template name.
Arguments:
template_extension: defaults to the instance's extension.
"""
file_name
=
template_name
if
self
.
template_extension
is
not
False
:
file_name
+=
os
.
path
.
extsep
+
self
.
template_extension
if
template_extension
is
None
:
template_extension
=
self
.
template_extension
if
template_extension
is
not
False
:
file_name
+=
os
.
path
.
extsep
+
template_extension
return
file_name
...
...
tests/test_locator.py
View file @
78ef793b
...
...
@@ -63,6 +63,11 @@ class LocatorTests(unittest.TestCase):
locator
.
template_extension
=
''
self
.
assertEquals
(
locator
.
make_file_name
(
'foo'
),
'foo.'
)
def
test_make_file_name__template_extension_argument
(
self
):
locator
=
Locator
()
self
.
assertEquals
(
locator
.
make_file_name
(
'foo'
,
template_extension
=
'bar'
),
'foo.bar'
)
def
test_find_path_by_name
(
self
):
locator
=
Locator
()
path
=
locator
.
find_path_by_name
(
search_dirs
=
[
'examples'
],
template_name
=
'simple'
)
...
...
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