Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def render_testapp(req):
try:
import pkg_resources
except ImportError:
eggs = ()
else:
eggs = sorted(pkg_resources.working_set,
key=lambda x: x.project_name.lower())
python_eggs = []
for egg in eggs:
try:
version = egg.version
except (ValueError, AttributeError):
version = 'unknown'
python_eggs.append('<li>%s <small>[%s]</small>' % (
escape(egg.project_name),
escape(version)
))
wsgi_env = []
sorted_environ = sorted(req.environ.items(),
key=lambda x: repr(x[0]).lower())
for key, value in sorted_environ:
wsgi_env.append('%s<code>%s</code>' % (
escape(str(key)),
' '.join(wrap(escape(repr(value))))
))
sys_path = []
for item, virtual, expanded in iter_sys_path():
class_ = []
if virtual:</li>
for link in self.links:
yield u' \n' % ''.join('%s="%s" ' %
(k, escape(link[k])) for k in link)
for author in self.author:
yield u' \n'
yield u' %s\n' % escape(author['name'])
if 'uri' in author:
yield u' %s\n' % escape(author['uri'])
if 'email' in author:
yield ' %s\n' % escape(author['email'])
yield ' \n'
if self.subtitle:
yield ' ' + _make_text_block('subtitle', self.subtitle,
self.subtitle_type)
if self.icon:
yield u' %s\n' % escape(self.icon)
if self.logo:
yield u' %s\n' % escape(self.logo)
if self.rights:
yield ' ' + _make_text_block('rights', self.rights,
self.rights_type)
generator_name, generator_url, generator_version = self.generator
if generator_name or generator_url or generator_version:
tmp = [u' %s\n' % escape(generator_name))
yield u''.join(tmp)
for entry in self.entries:
for line in entry.generate():
def generate(self):
"""Yields pieces of ATOM XML."""
base = ''
if self.xml_base:
base = ' xml:base="%s"' % escape(self.xml_base)
yield u'\n' % base
yield u' ' + _make_text_block('title', self.title, self.title_type)
yield u' %s\n' % escape(self.id)
yield u' %s\n' % format_iso8601(self.updated)
if self.published:
yield u' %s\n' % \
format_iso8601(self.published)
if self.url:
yield u' \n' % escape(self.url)
for author in self.author:
yield u' \n'
yield u' %s\n' % escape(author['name'])
if 'uri' in author:
yield u' %s\n' % escape(author['uri'])
if 'email' in author:
yield u' %s\n' % escape(author['email'])
yield ' ' + _make_text_block('subtitle', self.subtitle,
self.subtitle_type)
if self.icon:
yield u' %s\n' % escape(self.icon)
if self.logo:
yield u' %s\n' % escape(self.logo)
if self.rights:
yield ' ' + _make_text_block('rights', self.rights,
self.rights_type)
generator_name, generator_url, generator_version = self.generator
if generator_name or generator_url or generator_version:
tmp = [u' %s\n' % escape(generator_name))
yield u''.join(tmp)
for entry in self.entries:
for line in entry.generate():
yield u' ' + line
yield u'\n'
def _make_text_block(name, content, content_type=None):
"""Helper function for the builder that creates an XML text block."""
if content_type == 'xhtml':
return u'<%s type="xhtml"><div xmlns="%s">%s</div>\n' % \
(name, XHTML_NAMESPACE, content, name)
if not content_type:
return u'<%s>%s\n' % (name, escape(content), name)
return u'<%s type="%s">%s\n' % (name, content_type,
escape(content), name)
(k, escape(link[k], True)) for k in link)
for author in self.author:
yield u' \n'
yield u' %s\n' % escape(author['name'])
if 'uri' in author:
yield u' %s\n' % escape(author['uri'])
if 'email' in author:
yield ' %s\n' % escape(author['email'])
yield ' \n'
if self.subtitle:
yield ' ' + _make_text_block('subtitle', self.subtitle,
self.subtitle_type)
if self.icon:
yield u' %s\n' % escape(self.icon)
if self.logo:
yield u' %s\n' % escape(self.logo)
if self.rights:
yield ' ' + _make_text_block('rights', self.rights,
self.rights_type)
generator_name, generator_url, generator_version = self.generator
if generator_name or generator_url or generator_version:
tmp = [u' %s\n' % escape(generator_name))
yield u''.join(tmp)
for entry in self.entries:
for line in entry.generate():
yield u' ' + line
yield u'\n'
yield ' \n'
if self.subtitle:
yield ' ' + _make_text_block('subtitle', self.subtitle,
self.subtitle_type)
if self.icon:
yield u' %s\n' % escape(self.icon)
if self.logo:
yield u' %s\n' % escape(self.logo)
if self.rights:
yield ' ' + _make_text_block('rights', self.rights,
self.rights_type)
generator_name, generator_url, generator_version = self.generator
if generator_name or generator_url or generator_version:
tmp = [u' %s\n' % escape(generator_name))
yield u''.join(tmp)
for entry in self.entries:
for line in entry.generate():
yield u' ' + line
yield u'\n'
def _make_text_block(name, content, content_type=None):
"""Helper function for the builder that creates an XML text block."""
if content_type == 'xhtml':
return u'<%s type="xhtml"><div xmlns="%s">%s</div>\n' % \
(name, XHTML_NAMESPACE, content, name)
if not content_type:
return u'<%s>%s\n' % (name, escape(content), name)
return u'<%s type="%s">%s\n' % (name, content_type,
escape(content), name)
def writelines(self, x):
self._write(escape(''.join(x)))
self.subtitle_type)
if self.icon:
yield u' %s\n' % escape(self.icon)
if self.logo:
yield u' %s\n' % escape(self.logo)
if self.rights:
yield ' ' + _make_text_block('rights', self.rights,
self.rights_type)
generator_name, generator_url, generator_version = self.generator
if generator_name or generator_url or generator_version:
tmp = [u' %s\n' % escape(generator_name))
yield u''.join(tmp)
for entry in self.entries:
for line in entry.generate():
yield u' ' + line
yield u'\n'