Andriy Kornatskyy avatar Andriy Kornatskyy committed b37e747

Eliminated SelfClosingTag; Optimized Tag.render call

Comments (0)

Files changed (1)

src/wheezy/html/markup.py

     """
     __slots__ = ['name', 'inner', 'attrs']
 
-    def __init__(self, name, inner=None, attrs=None):
+    def __init__(self, name, inner, attrs):
         self.name = name
         self.inner = inner
         self.attrs = attrs
         """
         name = self.name
         attrs = self.attrs
-        if attrs is None:
-            t = '<' + name
-        else:
-            t = '<' + name + ' ' + ' '.join(
+        t = '<' + name + ' ' + ' '.join(
                     [k.rstrip('_') + '="' + attrs[k] + '"'
                         for k in attrs])
         inner = self.inner
         else:
             return t + '>' + str_type(inner) + '</' + name + '>'
 
-    if PY3:
+    if PY3:  # pragma: nocover
         __str__ = render
-    else:
-        __unicode__ = render
-
-
-class SelfClosingTag(object):
-    """ Represents object version of HTML self closing tag.
-    """
-    __slots__ = ['name', 'attrs']
-
-    def __init__(self, name, attrs):
-        self.name = name
-        self.attrs = attrs
-
-    def __repr__(self):
-        return str(self.render())
-
-    def render(self):
-        attrs = self.attrs
-        return self.name + ' '.join(
-                [k.rstrip('_') + '="' + attrs[k] + '"'
-                    for k in attrs]) + ' />'
-
-    if PY3:
-        __str__ = render
-    else:
+    else:  # pragma: nocover
         __unicode__ = render
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.