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
00090310
Commit
00090310
authored
Mar 28, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a defaults module with default DECODE_ERRORS and TEMPLATE_EXTENSION values.
parent
9909ec90
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
14 deletions
+32
-14
pystache/defaults.py
+18
-0
pystache/loader.py
+4
-5
pystache/locator.py
+5
-5
pystache/renderer.py
+5
-4
No files found.
pystache/defaults.py
0 → 100644
View file @
00090310
# coding: utf-8
"""
This module provides a central location for defining default behavior.
"""
# How to handle encoding errors when decoding strings from str to unicode.
#
# This value is passed as the "errors" argument to Python's built-in
# unicode() function:
#
# http://docs.python.org/library/functions.html#unicode
#
DECODE_ERRORS
=
'strict'
# The default template extension.
TEMPLATE_EXTENSION
=
'mustache'
pystache/loader.py
View file @
00090310
...
@@ -10,8 +10,7 @@ from __future__ import with_statement
...
@@ -10,8 +10,7 @@ from __future__ import with_statement
import
os
import
os
import
sys
import
sys
from
.
import
defaults
DEFAULT_DECODE_ERRORS
=
'strict'
class
Loader
(
object
):
class
Loader
(
object
):
...
@@ -29,12 +28,12 @@ class Loader(object):
...
@@ -29,12 +28,12 @@ class Loader(object):
sys.getdefaultencoding().
sys.getdefaultencoding().
decode_errors: the string to pass as the errors argument to the
decode_errors: the string to pass as the errors argument to the
built-in function unicode() when converting
file content
s to
built-in function unicode() when converting
str string
s to
unicode. Defaults to
"strict"
.
unicode. Defaults to
the package default
.
"""
"""
if
decode_errors
is
None
:
if
decode_errors
is
None
:
decode_errors
=
DEFAULT_
DECODE_ERRORS
decode_errors
=
defaults
.
DECODE_ERRORS
if
encoding
is
None
:
if
encoding
is
None
:
encoding
=
sys
.
getdefaultencoding
()
encoding
=
sys
.
getdefaultencoding
()
...
...
pystache/locator.py
View file @
00090310
...
@@ -9,8 +9,7 @@ import os
...
@@ -9,8 +9,7 @@ import os
import
re
import
re
import
sys
import
sys
from
.
import
defaults
DEFAULT_EXTENSION
=
'mustache'
class
Locator
(
object
):
class
Locator
(
object
):
...
@@ -21,12 +20,13 @@ class Locator(object):
...
@@ -21,12 +20,13 @@ class Locator(object):
Arguments:
Arguments:
extension: the template file extension. Defaults to "mustache".
extension: the template file extension. Pass False for no
Pass False for no extension (i.e. extensionless template files).
extension (i.e. to use extensionless template files).
Defaults to the package default.
"""
"""
if
extension
is
None
:
if
extension
is
None
:
extension
=
DEFAULT
_EXTENSION
extension
=
defaults
.
TEMPLATE
_EXTENSION
self
.
template_extension
=
extension
self
.
template_extension
=
extension
...
...
pystache/renderer.py
View file @
00090310
...
@@ -9,10 +9,10 @@ import cgi
...
@@ -9,10 +9,10 @@ import cgi
import
os
import
os
import
sys
import
sys
from
.
import
defaults
from
.context
import
Context
from
.context
import
Context
# TODO: remove this alias.
# TODO: remove this alias.
from
.loader
import
Loader
as
Reader
from
.loader
import
Loader
as
Reader
from
.locator
import
DEFAULT_EXTENSION
from
.locator
import
Locator
from
.locator
import
Locator
from
.renderengine
import
RenderEngine
from
.renderengine
import
RenderEngine
...
@@ -96,8 +96,9 @@ class Renderer(object):
...
@@ -96,8 +96,9 @@ class Renderer(object):
current working directory. If given a string, the string is
current working directory. If given a string, the string is
interpreted as a single directory.
interpreted as a single directory.
file_extension: the template file extension. Defaults to "mustache".
file_extension: the template file extension. Pass False for no
Pass False for no extension (i.e. for extensionless files).
extension (i.e. to use extensionless template files).
Defaults to the package default.
"""
"""
if
default_encoding
is
None
:
if
default_encoding
is
None
:
...
@@ -111,7 +112,7 @@ class Renderer(object):
...
@@ -111,7 +112,7 @@ class Renderer(object):
file_encoding
=
default_encoding
file_encoding
=
default_encoding
if
file_extension
is
None
:
if
file_extension
is
None
:
file_extension
=
DEFAULT
_EXTENSION
file_extension
=
defaults
.
TEMPLATE
_EXTENSION
if
search_dirs
is
None
:
if
search_dirs
is
None
:
search_dirs
=
os
.
curdir
# i.e. "."
search_dirs
=
os
.
curdir
# i.e. "."
...
...
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