Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
Template
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
Template
Commits
d88ddd1c
Commit
d88ddd1c
authored
8 years ago
by
nimrod
Browse files
Options
Downloads
Plain Diff
Merge branch 'feature/toml'
parents
00a42412
909569c2
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.rst
+2
-1
2 additions, 1 deletion
README.rst
setup.py
+1
-1
1 addition, 1 deletion
setup.py
template/filters.py
+23
-0
23 additions, 0 deletions
template/filters.py
with
26 additions
and
2 deletions
README.rst
+
2
−
1
View file @
d88ddd1c
...
...
@@ -45,6 +45,8 @@ The following Jinja filters were added:
- :code:`from_json`: Convert from json.
- :code:`pprint`: Pretty print variable.
- :code:`combine`: Combine 2 dictionaries.
- :code:`to_toml`: Convert to toml.
- :code:`from_toml`: Convert from toml.
- :code:`jmespath`: Queries data using the `JMESPath <http://jmespath.org/>`_
query language.
...
...
@@ -87,4 +89,3 @@ TODO
- Release on tagged commits to PyPI in Travis CI
(https://docs.travis-ci.com/user/deployment/pypi/ and
https://docs.travis-ci.com/user/encryption-keys/).
- Add TOML support?
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
1
View file @
d88ddd1c
...
...
@@ -21,7 +21,7 @@ setup(
],
keywords
=
'
config configuration jinja template environment
'
,
packages
=
find_packages
(),
install_requires
=
[
'
Jinja2
'
,
'
PyYAML
'
,
'
jmespath
'
],
install_requires
=
[
'
Jinja2
'
,
'
PyYAML
'
,
'
jmespath
'
,
'
toml
'
],
extras_require
=
{
'
dev
'
:
[
'
tox
'
],
},
entry_points
=
{
...
...
This diff is collapsed.
Click to expand it.
template/filters.py
+
23
−
0
View file @
d88ddd1c
...
...
@@ -104,6 +104,29 @@ def combine(default, override):
return
combined
def
from_toml
(
value
):
'''
Returns a data structure from the TOML string given.
Examples:
>>>
from_toml
(
'
[table]
\\
nkey =
"
value
"
\\
n
'
)
==
{
'
table
'
:
{
'
key
'
:
'
value
'
}}
True
'''
from
toml
import
loads
return
loads
(
value
)
def
to_toml
(
value
):
'''
Returns a string of the TOML representation for the data structure given.
Examples:
>>>
import
six
>>>
to_toml
({
'
key
'
:
[
1
,
2
]})
==
six
.
text_type
(
"
key = [ 1, 2,]
\\
n
"
)
True
'''
from
toml
import
dumps
return
dumps
(
value
)
def
jmespath
(
value
,
query
):
'''
Queries the data using the JMESPath query language.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment