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


Python PyQuery.get方法代码示例

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


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

示例1: test_meeting_link

# 需要导入模块: from pyquery import PyQuery [as 别名]
# 或者: from pyquery.PyQuery import get [as 别名]
    def test_meeting_link(self):
        self.login(self.committee_responsible)

        link = PyQuery(self.meeting.model.get_link())[0]

        self.assertEqual(
            'http://nohost/plone/opengever-meeting-committeecontainer/committee-1/meeting-1/view',
            link.get('href'))
        self.assertEqual('contenttype-opengever-meeting-meeting', link.get('class'))
        self.assertEqual(u'9. Sitzung der Rechnungspr\xfcfungskommission',
                         link.get('title'))
        self.assertEqual(u'9. Sitzung der Rechnungspr\xfcfungskommission',
                         link.text)
开发者ID:4teamwork,项目名称:opengever.core,代码行数:15,代码来源:test_meeting.py

示例2: handle

# 需要导入模块: from pyquery import PyQuery [as 别名]
# 或者: from pyquery.PyQuery import get [as 别名]
	def handle(self, *args, **options):
		xml = ElementTree.parse(open(args[0], 'r'))
		channel = xml.find('channel')
		
		def node_text(node, namespace = None, parent = None):
			if namespace:
				item = (parent or channel).find(ns(namespace, node))
			else:
				item = (parent or channel).find(node)
			
			if not item is None:
				return item.text
			
			return None
		
		def ns(n, o):
			return '{%s}%s' % (XML_NS[n], o)
		
		if channel is None:
			raise CommandError('Cannot find <channel> tag')
		
		title = node_text('title')
		if title:
			print(u'Blog title: %s' % title)
		
		link = node_text('link')
		if link:
			print(u'Blog URL: %s' % link)
		
		description = node_text('description')
		if description:
			print(u'Blog description: %s' % description)
		
		mappings = {
			'users': {},
			'posts': {},
			'categories': {},
			'comments': {}
		}
		
		content_type = ContentType.objects.get_for_model(Post)
		site = Site.objects.get_current()
		postmeta = {}
		
		print
		with transaction.commit_manually():
			try:
				for author in channel.findall(ns('wp', 'wp_author')):
					username = node_text('author_login', 'wp', author)
					email = node_text('author_email', 'wp', author)
					display_name = node_text('author_display_name', 'wp', author)
					user = None
					
					if not username:
						continue
					
					if display_name:
						display_name = '%s (%s)' % (username, display_name)
					else:
						display_name = username
					
					try:
						user = User.objects.get(username__iexact = username)
					except User.DoesNotExist:
						if email:
							try:
								user = User.objects.get(email__iexact = email)
							except:
								pass
					
					if not user:
						new_username = raw_input('Map old user %s to a user in your database: ' % display_name)
						if not new_username:
							continue
						
						while True:
							try:
								user = User.objects.get(username__iexact = new_username)
								break
							except User.DoesNotExist:
								new_username = raw_input('User not found. Please try again ,or press Enter to ignore: ')
								if not new_username:
									print 'Ignoring user %s' % username
									break
					
					if user:
						mappings['users'][username] = user
						print 'Mapping user %s to %s' % (
							username, user.get_full_name() or user.username
						)
				
				for item in channel.findall('item'):
					id = node_text('post_id', 'wp', item)
					title = node_text('title', parent = item)
					url = node_text('link', parent = item)
					kind = node_text('post_type', 'wp', item)
					parent = node_text('post_parent', 'wp', item)
					published = node_text('status', 'wp', item) == 'publish'
					author = node_text('creator', 'dc', item)
					date = node_text('post_date_gmt', 'wp', item)
#.........这里部分代码省略.........
开发者ID:iamsteadman,项目名称:bambu-tools,代码行数:103,代码来源:wpimport.py


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