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
Show 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
import
os
import
sys
DEFAULT_DECODE_ERRORS
=
'strict'
from
.
import
defaults
class
Loader
(
object
):
...
...
@@ -29,12 +28,12 @@ class Loader(object):
sys.getdefaultencoding().
decode_errors: the string to pass as the errors argument to the
built-in function unicode() when converting
file content
s to
unicode. Defaults to
"strict"
.
built-in function unicode() when converting
str string
s to
unicode. Defaults to
the package default
.
"""
if
decode_errors
is
None
:
decode_errors
=
DEFAULT_
DECODE_ERRORS
decode_errors
=
defaults
.
DECODE_ERRORS
if
encoding
is
None
:
encoding
=
sys
.
getdefaultencoding
()
...
...
pystache/locator.py
View file @
00090310
...
...
@@ -9,8 +9,7 @@ import os
import
re
import
sys
DEFAULT_EXTENSION
=
'mustache'
from
.
import
defaults
class
Locator
(
object
):
...
...
@@ -21,12 +20,13 @@ class Locator(object):
Arguments:
extension: the template file extension. Defaults to "mustache".
Pass False for no extension (i.e. extensionless template files).
extension: the template file extension. Pass False for no
extension (i.e. to use extensionless template files).
Defaults to the package default.
"""
if
extension
is
None
:
extension
=
DEFAULT
_EXTENSION
extension
=
defaults
.
TEMPLATE
_EXTENSION
self
.
template_extension
=
extension
...
...
pystache/renderer.py
View file @
00090310
...
...
@@ -9,10 +9,10 @@ import cgi
import
os
import
sys
from
.
import
defaults
from
.context
import
Context
# TODO: remove this alias.
from
.loader
import
Loader
as
Reader
from
.locator
import
DEFAULT_EXTENSION
from
.locator
import
Locator
from
.renderengine
import
RenderEngine
...
...
@@ -96,8 +96,9 @@ class Renderer(object):
current working directory. If given a string, the string is
interpreted as a single directory.
file_extension: the template file extension. Defaults to "mustache".
Pass False for no extension (i.e. for extensionless files).
file_extension: the template file extension. Pass False for no
extension (i.e. to use extensionless template files).
Defaults to the package default.
"""
if
default_encoding
is
None
:
...
...
@@ -111,7 +112,7 @@ class Renderer(object):
file_encoding
=
default_encoding
if
file_extension
is
None
:
file_extension
=
DEFAULT
_EXTENSION
file_extension
=
defaults
.
TEMPLATE
_EXTENSION
if
search_dirs
is
None
:
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