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


Python Element.isempty方法代码示例

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


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

示例1: main

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import isempty [as 别名]

#.........这里部分代码省略.........
			sp_source = sp_ctype_fieldnames

		# If we are processing a list, fetch the existing list
		if self.args.type == 'list':
			sp_list = self.adsm_lists.service.GetList(self.args.spec)
			sp_list_fieldnames = set(f._Name for f in sp_list.List.Fields.Field)
			sp_source = sp_list_fieldnames

		# Holds fields for the current operation
		op_fields = Element('Fields')

		for row_idx in range(1, sheet.nrows):
			row = sheet.row(row_idx)
			c = lambda x: row[cols[x]].value

			# Skip rows that do not match sub-type, or rows with a sub-type if one is
			# not defined.
			if (sub_type and c('Content Type') != sub_type) or (not sub_type and c('Content Type')):
				continue

			# Skip rows that do not have an internal name. An internal name is required
			# to reference in SharePoint.
			if not c('Field Internal Name'):
				continue

			# If creating, check that the row doesn't already exist
			if self.args.op == 'new' and c('Field Internal Name') in sp_source:
				continue

			sp_args = json.loads(c('Type Arguments')) if c('Type Arguments')else {}
			if sp_args.get('SPDefined', False):
				continue

			method = Element('Method').append(Attribute('ID', row_idx))
			field = Element('Field')

			if self.args.op == 'delete':
				# if sp_args.get('SPDelete', False) and c('Field Internal Name') in sp_source:
				if c('Field Internal Name') in sp_source:
					if self.args.type == 'columns' and sp_source[c('Field Internal Name')]._Group != self.args.spec:
						continue
					field.set('Name', c('Field Internal Name'))
				else:
					continue
			else:
				attrs = [
					('DisplayName', c('Field Internal Name') if self.args.op is 'new' else c('Field Display Name')),
					('Name', c('Field Internal Name')),
					('Description', c('Description')),
					('Type', c('Type')),
					('List', c('Values') if c('Type') == 'Lookup' else None)
				]

				if not c('Type'):
					sys.exit('Missing type for ' + c('Field Display Name'))

				if self.args.type == 'columns':
					attrs.append(('Group', self.args.spec))
				elif self.args.type == 'content-type':
					site_col = sp_columns.get(c('Field Internal Name'))
					attrs.append(('ID', site_col['_ID']))
					attrs.append(('SourceID', site_col['_SourceID']))

				for att, value in attrs:
					if value:
						field.set(att, value)

				if c('Type') in ('Choice', 'MultiChoice'):
					choices = Element('CHOICES')
					for c in c('Values').splitlines(False):
						choices.append(Element('CHOICE').setText(c))
					field.append(choices)

				if sp_args:
					for k, v in sp_args.items():
						if k == 'FieldRefs':
							refs = Element(k)
							for t in v:
								refs.append(Element('FieldRef').append(Attribute('Name', t)))
							field.append(refs)
						elif k in ('Default', 'Formula'):
							field.append(Element(k).setText(v))
						else:
							field.set(k, v)

			method.append(field)
			op_fields.append(method)

		print '---Fields---'
		print op_fields

		if not op_fields.isempty() and not self.args.d:
			v = self.args.op + 'Fields'

			if self.args.type == 'columns':
				print self.adsm_webs.service.UpdateColumns(**{v:Element('ns1:%s' % v).append(op_fields)})
			elif self.args.type == 'content-type':
				print self.adsm_webs.service.UpdateContentType(contentTypeId=self.args.spec, **{v:Element('ns1:%s' % v).append(op_fields)})
			elif self.args.type == 'list':
				print self.adsm_lists.service.UpdateList(listName=self.args.spec, **{v:Element('ns1:%s' % v).append(op_fields)})
开发者ID:kinghuang,项目名称:itsm,代码行数:104,代码来源:push-to-sp.py


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