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
36d7fdea
Commit
36d7fdea
authored
8 years ago
by
nimrod
Browse files
Options
Downloads
Patches
Plain Diff
- Added doctests to pprint and combine filters.
parent
deb72e34
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
template/filters.py
+20
-0
20 additions, 0 deletions
template/filters.py
with
20 additions
and
0 deletions
template/filters.py
+
20
−
0
View file @
36d7fdea
...
...
@@ -72,11 +72,31 @@ def from_yaml(value):
def
pprint
(
value
):
'''
Returns a pretty string representation of the data structure given.
Examples:
>>>
pprint
(
1
)
'
1
'
>>>
pprint
([{
'
first_name
'
:
'
John
'
,
'
last_name
'
:
'
Doe
'
},
{
'
first_name
'
:
'
Jane
'
,
'
last_name
'
:
'
Doe
'
}])
# noqa: E501
"
[{
'
first_name
'
:
'
John
'
,
'
last_name
'
:
'
Doe
'
},
\\
n {
'
first_name
'
:
'
Jane
'
,
'
last_name
'
:
'
Doe
'
}]
"
'''
from
pprint
import
pformat
return
pformat
(
value
)
def
combine
(
default
,
override
):
'''
Returns a combined dictionary of the 2 dictionaries given (with the 2nd
overriding the 1st).
Examples:
>>>
combined
=
combine
({
'
a
'
:
1
,
'
b
'
:
2
},
{
'
b
'
:
3
,
'
c
'
:
4
})
>>>
'
a
'
in
combined
True
>>>
'
c
'
in
combined
True
>>>
combined
[
'
b
'
]
==
3
True
'''
combined
=
default
.
copy
()
combined
.
update
(
override
)
return
combined
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