本文整理汇总了Python中orgmode.liborgmode.base.MultiPurposeList类的典型用法代码示例。如果您正苦于以下问题:Python MultiPurposeList类的具体用法?Python MultiPurposeList怎么用?Python MultiPurposeList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MultiPurposeList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: append
def append(self, item, taint=True):
if not self.__class__.is_heading(item):
raise ValueError(u"Item is not a heading!")
if item in self:
raise ValueError(u"Heading is already part of this list!")
self._associate_heading(item, self[-1] if len(self) > 0 else None, None, taint=taint)
MultiPurposeList.append(self, item)
示例2: __setitem__
def __setitem__(self, i, item):
if isinstance(i, slice):
o = item
if self.__class__.is_domobj(o):
o = (o, )
o = flatten_list(o)
for item in o:
if not self.__class__.is_domobj(item):
raise ValueError(u'List contains items that are not a Dom obj!')
# self._add_to_deleted_domobjs(self[i:j])
# self._associate_domobj(o, \
# self[i - 1] if i - 1 >= 0 and i < len(self) else None, \
# self[j] if j >= 0 and j < len(self) else None)
MultiPurposeList.__setitem__(self, i, o)
else:
if not self.__class__.is_domobj(item):
raise ValueError(u'Item is not a Dom obj!')
if item in self:
raise ValueError(u'Dom obj is already part of this list!')
# self._add_to_deleted_domobjs(self[i])
# self._associate_domobj(item, \
# self[i - 1] if i - 1 >= 0 else None, \
# self[i + 1] if i + 1 < len(self) else None)
MultiPurposeList.__setitem__(self, i, item)
示例3: __setitem__
def __setitem__(self, i, item):
if isinstance(i, slice):
start, stop, step = i.indices(len(self))
items = item
if self.__class__.is_heading(items):
items = (items, )
items = flatten_list(items)
for head in items:
if not self.__class__.is_heading(head):
raise ValueError(u'List contains items that are not a heading!')
self._add_to_deleted_headings(self[i])
self._associate_heading(
items,
self[start - 1] if start - 1 >= 0 else None,
self[stop] if stop < len(self) else None)
MultiPurposeList.__setitem__(self, i, items)
else:
if not self.__class__.is_heading(item):
raise ValueError(u'Item is not a heading!')
if item in self:
raise ValueError(u'Heading is already part of this list!')
self._add_to_deleted_headings(self[i])
self._associate_heading(
item,
self[i - 1] if i - 1 >= 0 else None,
self[i + 1] if i + 1 < len(self) else None)
MultiPurposeList.__setitem__(self, i, item)
示例4: insert
def insert(self, i, item, taint=True):
self._associate_heading(
item,
self[i - 1] if i - 1 >= 0 and i - 1 < len(self) else None,
self[i] if i >= 0 and i < len(self) else None,
taint=taint,
)
MultiPurposeList.insert(self, i, item)
示例5: __delitem__
def __delitem__(self, i):
item = self[i]
if item.previous_sibling:
item.previous_sibling._next_sibling = item.next_sibling
if item.next_sibling:
item.next_sibling._previous_sibling = item.previous_sibling
self._add_to_deleted_headings(item)
MultiPurposeList.__delitem__(self, i)
示例6: __setitem__
def __setitem__(self, i, item):
if not self.__class__.is_heading(item):
raise ValueError(u"Item is not a heading!")
if item in self:
raise ValueError(u"Heading is already part of this list!")
self._add_to_deleted_headings(self[i])
self._associate_heading(item, self[i - 1] if i - 1 >= 0 else None, self[i + 1] if i + 1 < len(self) else None)
MultiPurposeList.__setitem__(self, i, item)
示例7: extend
def extend(self, other):
o = other
if self.__class__.is_domobj(o):
o = (o, )
for item in o:
if not self.__class__.is_domobj(item):
raise ValueError(u'List contains items that are not a heading!')
# self._associate_domobj(o, self[-1] if len(self) > 0 else None, None)
MultiPurposeList.extend(self, o)
示例8: reverse
def reverse(self):
MultiPurposeList.reverse(self)
prev_h = None
for h in self:
h._previous_sibling = prev_h
h._next_sibling = None
prev_h._next_sibling = h
h.set_dirty()
prev_h = h
示例9: sort
def sort(self, *args, **kwds):
MultiPurposeList.sort(*args, **kwds)
prev_h = None
for h in self:
h._previous_sibling = prev_h
h._next_sibling = None
prev_h._next_sibling = h
h.set_dirty()
prev_h = h
示例10: append
def append(self, item, taint=True):
if not self.__class__.is_domobj(item):
raise ValueError(u'Item is not a heading!')
if item in self:
raise ValueError(u'Heading is already part of this list!')
# self._associate_domobj(
# item, self[-1] if len(self) > 0 else None,
# None, taint=taint)
MultiPurposeList.append(self, item)
示例11: __delitem__
def __delitem__(self, i, taint=True):
item = self[i]
if item.previous_sibling:
item.previous_sibling._next_sibling = item.next_sibling
if item.next_sibling:
item.next_sibling._previous_sibling = item.previous_sibling
# if taint:
# self._add_to_deleted_domobjs(item)
MultiPurposeList.__delitem__(self, i)
示例12: __setitem__
def __setitem__(self, i, item):
if not self.__class__.is_domobj(item):
raise ValueError(u'Item is not a Dom obj!')
if item in self:
raise ValueError(u'Dom obj is already part of this list!')
# self._add_to_deleted_domobjs(self[i])
# self._associate_domobj(item, \
# self[i - 1] if i - 1 >= 0 else None, \
# self[i + 1] if i + 1 < len(self) else None)
MultiPurposeList.__setitem__(self, i, item)
示例13: __delslice__
def __delslice__(self, i, j):
i = max(i, 0)
j = max(j, 0)
items = self[i:j]
if items:
first = items[0]
last = items[-1]
if first.previous_sibling:
first.previous_sibling._next_sibling = last.next_sibling
if last.next_sibling:
last.next_sibling._previous_sibling = first.previous_sibling
self._add_to_deleted_headings(items)
MultiPurposeList.__delslice__(self, i, j)
示例14: __delslice__
def __delslice__(self, i, j, taint=True):
i = max(i, 0)
j = max(j, 0)
items = self[i:j]
if items:
first = items[0]
last = items[-1]
if first.previous_sibling:
first.previous_sibling._next_sibling = last.next_sibling
if last.next_sibling:
last.next_sibling._previous_sibling = first.previous_sibling
# if taint:
# self._add_to_deleted_domobjs(items)
MultiPurposeList.__delslice__(self, i, j)
示例15: __setslice__
def __setslice__(self, i, j, other):
o = other
if self.__class__.is_heading(o):
o = (o, )
o = flatten_list(o)
for item in o:
if not self.__class__.is_heading(item):
raise ValueError(u'List contains items that are not a heading!')
i = max(i, 0)
j = max(j, 0)
self._add_to_deleted_headings(self[i:j])
self._associate_heading(o, \
self[i - 1] if i - 1 >= 0 and i < len(self) else None, \
self[j] if j >= 0 and j < len(self) else None)
MultiPurposeList.__setslice__(self, i, j, o)