当前位置: 首页>>代码示例>>Python>>正文


Python MultiPurposeList.__setitem__方法代码示例

本文整理汇总了Python中orgmode.liborgmode.base.MultiPurposeList.__setitem__方法的典型用法代码示例。如果您正苦于以下问题:Python MultiPurposeList.__setitem__方法的具体用法?Python MultiPurposeList.__setitem__怎么用?Python MultiPurposeList.__setitem__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在orgmode.liborgmode.base.MultiPurposeList的用法示例。


在下文中一共展示了MultiPurposeList.__setitem__方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __setitem__

# 需要导入模块: from orgmode.liborgmode.base import MultiPurposeList [as 别名]
# 或者: from orgmode.liborgmode.base.MultiPurposeList import __setitem__ [as 别名]
	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)
开发者ID:Ron89,项目名称:vim-orgmode,代码行数:28,代码来源:dom_obj.py

示例2: __setitem__

# 需要导入模块: from orgmode.liborgmode.base import MultiPurposeList [as 别名]
# 或者: from orgmode.liborgmode.base.MultiPurposeList import __setitem__ [as 别名]
	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)
开发者ID:Ron89,项目名称:vim-orgmode,代码行数:30,代码来源:headings.py

示例3: __setitem__

# 需要导入模块: from orgmode.liborgmode.base import MultiPurposeList [as 别名]
# 或者: from orgmode.liborgmode.base.MultiPurposeList import __setitem__ [as 别名]
    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)
开发者ID:oyslboy,项目名称:config,代码行数:11,代码来源:headings.py

示例4: __setitem__

# 需要导入模块: from orgmode.liborgmode.base import MultiPurposeList [as 别名]
# 或者: from orgmode.liborgmode.base.MultiPurposeList import __setitem__ [as 别名]
	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)
开发者ID:Yixf-Self,项目名称:vim-orgmode,代码行数:13,代码来源:dom_obj.py

示例5: __setitem__

# 需要导入模块: from orgmode.liborgmode.base import MultiPurposeList [as 别名]
# 或者: from orgmode.liborgmode.base.MultiPurposeList import __setitem__ [as 别名]
	def __setitem__(self, i, item):
		# TODO rewrite this so that it can work when item is a tuple and i is slice
		# it should be made to work with any item that is iterable
		# It is also very poor design to just check for tuple and not raise any
		# errors otherwise or implement list also
		# TODO slice must differentiate between couple of cases:
		# slice(None,None)
		# slice(int, None)
		# slice(None, int)
		# this must be done because of _associate_heading and other methods
		# that dont take into account slicing
		if isinstance(i, slice):
			# TODO fix this mess it is only copy pasted from setslice
			sl = i
			o = item
			if self.__class__.is_heading(o):
				o = (o, )
			o = flatten_list(o)
			for head in o:
				if not self.__class__.is_heading(head):
					raise ValueError(u'List contains items that are not a heading!')

			i = sl.start if sl.start is not None else 0
			j = sl.stop if sl.stop is not None else len(self) - 1

			self._add_to_deleted_headings(self[sl])
			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.__setitem__(self, sl, o)
		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)
开发者ID:Yixf-Self,项目名称:vim-orgmode,代码行数:45,代码来源:headings.py


注:本文中的orgmode.liborgmode.base.MultiPurposeList.__setitem__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。