Skip to content

Instantly share code, notes, and snippets.

@Eugeny
Created October 18, 2010 11:25
Show Gist options
  • Save Eugeny/632063 to your computer and use it in GitHub Desktop.
Save Eugeny/632063 to your computer and use it in GitHub Desktop.
import random
from lxml import etree
from ajenti.utils import fix_unicode
class Element(etree.ElementBase):
def __init__(self, tag, *args, **kwargs):
etree.ElementBase.__init__(self)
self.tag = tag
for k in args:
self.append(k)
for k in kwargs:
self[k] = kwargs[k]
def append(self, el):
if el is not None:
etree.ElementBase.append(self, el)
return self
def __setitem__(self, idx, val):
self.set(idx, fix_unicode(val))
def __getitem__(self, idx):
return self.get(idx)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment