⚲
Project
Profile
Help
Tour this page
Frequent Planio Questions
Learning Resources
Sign in
Register
Switch Planio account
Open in Planio App
Share current page
Search
:
Projects
All Projects
Help
Tour this page
Frequent Planio Questions
Learning Resources
Sign in
Register
Switch Planio account
Open in Planio App
Share current page
RPM Support
Overview
Roadmap
Issues
Gantt
Agile board
Calendar
Repository
Download (1.38 KB)
Issue #2077
ยป test.py
Suggested change -
fdobrovo
, 07/27/2016 02:36 PM
import
sys
from
django.template
import
Template
,
Context
other
=
"""<package arch="noarch" name="python-suds" pkgid="{{ pkgid }}">
<version epoch="0" rel="2.el5" ver="0.4.1" />
<changelog author="jortel <jortel@redhat.com> - 0.3.3-1" date="1228428000">
- Basic ws-security with {{{UsernameToken}}} and clear-text password only.</changelog>
</package>"""
con
=
Context
({
'pkgid'
:
u
'3201710bf51f8184571da00a060eab1a826cdb113dbe8598f08ff161f50c8ef1'
})
out_template
=
other
[:
other
.
find
(
">"
)
+
1
]
+
"{% verbatim %}"
+
other
[
other
.
find
(
">"
)
+
1
:
other
.
rfind
(
"</"
)]
+
"{% endverbatim %}"
+
other
[
other
.
rfind
(
"</"
):]
print
(
out_template
)
# Result:
# '<package arch="noarch" name="python-suds" pkgid="{{ pkgid }}">{% verbatim %}
# <version epoch="0" rel="2.el5" ver="0.4.1" />
# <changelog author="jortel <jortel@redhat.com> - 0.3.3-1" date="1228428000">
# - Basic ws-security with {{{UsernameToken}}} and clear-text password only.</changelog>
# {% endverbatim %}</package>'
t
=
Template
(
out_template
)
rendered
=
t
.
render
(
con
)
print
(
rendered
)
# Rendered:
# u'<package arch="noarch" name="python-suds" pkgid="3201710bf51f8184571da00a060eab1a826cdb113dbe8598f08ff161f50c8ef1">
# <version epoch="0" rel="2.el5" ver="0.4.1" />
# <changelog author="jortel <jortel@redhat.com> - 0.3.3-1" date="1228428000">
# - Basic ws-security with {{{UsernameToken}}} and clear-text password only.</changelog>
# </package>'
(1-1/1)
Loading...