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
c756f243
Commit
c756f243
authored
Mar 28, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added extension argument to Loader constructor.
parent
00090310
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
pystache/loader.py
+12
-4
tests/test_loader.py
+8
-0
No files found.
pystache/loader.py
View file @
c756f243
...
...
@@ -15,21 +15,25 @@ from . import defaults
class
Loader
(
object
):
def
__init__
(
self
,
encoding
=
None
,
decode_errors
=
None
):
def
__init__
(
self
,
encoding
=
None
,
decode_errors
=
None
,
extension
=
None
):
"""
Construct a template reader.
Arguments:
decode_errors: the string to pass as the errors argument to the
built-in function unicode() when converting str strings to
unicode. Defaults to the package default.
encoding: the file encoding. This is the name of the encoding to
use when converting file contents to unicode. This name is
passed as the encoding argument to Python's built-in function
unicode(). Defaults to the encoding name returned by
sys.getdefaultencoding().
decode_errors: the string to pass as the errors argument to the
built-in function unicode() when converting str strings to
unicode.
Defaults to the package default.
extension: the template file extension. Pass False for no
extension (i.e. to use extensionless template files).
Defaults to the package default.
"""
if
decode_errors
is
None
:
...
...
@@ -38,8 +42,12 @@ class Loader(object):
if
encoding
is
None
:
encoding
=
sys
.
getdefaultencoding
()
if
extension
is
None
:
extension
=
defaults
.
TEMPLATE_EXTENSION
self
.
decode_errors
=
decode_errors
self
.
encoding
=
encoding
self
.
extension
=
extension
def
unicode
(
self
,
s
,
encoding
=
None
):
"""
...
...
tests/test_loader.py
View file @
c756f243
...
...
@@ -38,6 +38,14 @@ class ReaderTestCase(unittest.TestCase, AssertStringMixin):
reader
=
Reader
(
encoding
=
'foo'
)
self
.
assertEquals
(
reader
.
encoding
,
'foo'
)
def
test_init__extension
(
self
):
# Test the default value.
reader
=
Reader
()
self
.
assertEquals
(
reader
.
extension
,
'mustache'
)
reader
=
Reader
(
extension
=
'foo'
)
self
.
assertEquals
(
reader
.
extension
,
'foo'
)
def
test_unicode__basic__input_str
(
self
):
"""
Test unicode(): default arguments with str input.
...
...
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