Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"Previously it was impossible to accurately determine across any Python package what "
"order the versions should go in, but with PEP386 we can now intelligently sort by version..."
"<br><br>"
"But only if the version numbers are compatible!"))
}
if self.version == normalized:
self._evaluate_pep386 = {
"level": "success",
"message": jinja2.Markup(_('Compatible with <a href="http://www.python.org/dev/peps/pep-0386/">PEP386</a>.')),
"evaluator": evaluator,
}
elif normalized is not None:
self._evaluate_pep386 = {
"level": None,
"message": jinja2.Markup(_('Almost Compatible with <a href="http://www.python.org/dev/peps/pep-0386/">PEP386</a>.')),
"evaluator": evaluator,
}
else:
self._evaluate_pep386 = {
"level": "error",
"message": jinja2.Markup(_('Incompatible with <a href="http://www.python.org/dev/peps/pep-0386/">PEP386</a>.')),
"evaluator": evaluator,
}
return self._evaluate_pep386
def user_activity_link(email: str) -> mark_safe:
url_name = 'analytics.views.get_user_activity'
url = reverse(url_name, kwargs=dict(email=email))
email_link = '<a href="%s">%s</a>' % (url, email)
return mark_safe(email_link)
def render_map():
css_js = ''
if conf.LOAD_CUSTOM_CSS_FILE:
css_js = ''
if conf.LOAD_CUSTOM_JS_FILE:
css_js += ''
js_vars = Markup(
"_defaultSettings['FIXED_OPACITY'] = '{:d}'; "
"_defaultSettings['SHOW_TIMER'] = '{:d}'; "
"_defaultSettings['TRASH_IDS'] = [{}]; ".format(conf.FIXED_OPACITY, conf.SHOW_TIMER, ', '.join(str(p_id) for p_id in conf.TRASH_IDS)))
template = env.get_template('custom.html' if conf.LOAD_CUSTOM_HTML_FILE else 'newmap.html')
return html(template.render(
area_name=conf.AREA_NAME,
map_center=center,
map_provider_url=conf.MAP_PROVIDER_URL,
map_provider_attribution=conf.MAP_PROVIDER_ATTRIBUTION,
social_links=social_links(),
init_js_vars=js_vars,
extra_css_js=Markup(css_js)
))
def do_render(self):
return jinja2.Markup(prism.handle_render(self.plugin_id, self.render))
def strip_controls(s):
"""
Strips control characters from a string.
"""
# Translation table of control characters.
control_trans = dict((n, None) for n in xrange(32) if n not in [10, 13])
rv = unicode(s).translate(control_trans)
return jinja2.Markup(rv) if isinstance(s, jinja2.Markup) else rv
def linebreaks(value):
return Markup(value.replace('\n', '<br>'))
if obj[0] == 'redirect':
obj = flask.redirect(flask.url_for(obj[1]))
elif obj[0] == 'abort':
obj = flask.abort(obj[1])
elif obj[0] == 'error':
error_json = base64.b64encode(json.dumps(page_args).encode('utf-8'))
obj = flask.redirect(flask.url_for('core.ErrorView', error_json=error_json))
elif isinstance(obj, str):
if obj.endswith('.html'):
obj = flask.render_template(obj)
elif get_url_for(obj) is not None:
obj = flask.redirect(get_url_for(obj))
elif isinstance(obj, dict):
obj = flask.jsonify(obj)
elif isinstance(obj, prism.api.view.View):
obj = jinja2.Markup(obj.render())
flask.g.current_plugin = hold_previous
return obj
def user_collection_list(collections=None, heading='', id='', link=None):
"""list of collections, as used on the user profile page"""
if collections is None:
collections = []
c = {'collections': collections, 'heading': heading, 'link': link,
'id': id}
template = loader.get_template('bandwagon/users/collection_list.html')
return jinja2.Markup(template.render(c))
def changecommentlink(changetext, project_name):
for pat, repl in REPLACEMENTS:
changetext = re.sub(pat, Markup(repl), changetext, flags=re.I)
return changetext
def replace_bugzilla_links(text):
"""Replaces "bug #xxx" with a link to bugzilla
Note, run this after escape::
{{ data | escape | replace_bugzilla_links }}
"""
# Convert text from Markup/str to a str so it doesn't escape the substituted
# text, then return as a Markup because it's safe
return jinja2.Markup(
BUG_RE.sub(
r'<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=\2">\1</a>',
str(text),
)