Exemplo n.º 1
0
 def __init__(self, name=None, element=None, icon=None):
     if element is None:
         element = Element('Group')
         name = xmlfactory.create_name_element(name)
         uuid = xmlfactory.create_uuid_element()
         element.append(uuid)
         element.append(name)
         if icon:
             icon_el = xmlfactory.create_icon_element(icon)
             element.append(icon_el)
     assert type(element) in [_Element, Element, ObjectifiedElement], \
         'The provided element is not an LXML Element, but {}'.format(
             type(element)
         )
     assert element.tag == 'Group', 'The provided element is not a Group '\
         'element, but a {}'.format(element.tag)
     self._element = element
Exemplo n.º 2
0
    def __init__(self,
                 title=None,
                 username=None,
                 password=None,
                 url=None,
                 notes=None,
                 tags=None,
                 expires=False,
                 expiry_time=None,
                 icon=None,
                 element=None):
        if element is None:
            element = Element('Entry')
            title = xmlfactory.create_title_element(title)
            uuid = xmlfactory.create_uuid_element()
            username = xmlfactory.create_username_element(username)
            password = xmlfactory.create_password_element(password)
            times = xmlfactory.create_times_element(expires, expiry_time)
            if url:
                url_el = xmlfactory.create_url_element(url)
                element.append(url_el)
            if notes:
                notes_el = xmlfactory.create_notes_element(notes)
                element.append(notes_el)
            if tags:
                tags_el = xmlfactory.create_tags_element(tags)
                element.append(tags_el)
            if icon:
                icon_el = xmlfactory.create_icon_element(icon)
                element.append(icon_el)
            element.append(title)
            element.append(uuid)
            element.append(username)
            element.append(password)
            element.append(times)
        assert type(element) in [_Element, Element, ObjectifiedElement], \
            'The provided element is not an LXML Element, but {}'.format(
                type(element)
            )
        assert element.tag == 'Entry', 'The provided element is not an Entry '\
            'element, but a {}'.format(element.tag)

        self._element = element