Пример #1
0
	def extract_inline_source(self):
		source = self.get_latest_source()
		doc = pyQ(source)
		sheets = doc.find('style')
		source = ''
		for sheet in sheets:
			source += pyQ(sheet).html()
Пример #2
0
	def sync_stylesheets(self):
		source = self.get_latest_source()
		doc = pyQ(source)
		links = doc.find('link[rel="stylesheet"]')
		inlineSheets = doc.find('style')
		for sheet in links:
			sheet = pyQ(sheet)
			href = sheet.attr('href')
			url = resolve_url(href, self.project.url);
			sheet = Stylesheet.objects.filter(project=self.project, url=url)
			if len(sheet) != 0:
				sheet = sheet[0]
			else:
				sheet = Stylesheet(url=url)
				sheet.user = self.user
				sheet.project = self.project
				sheet.save()
			sheet.paths.add(self)
			sheet.save()
Пример #3
0
	def extract_paths(self):
		project = self.project
		user = self.user
		base = ApplicationPath.objects.filter(project=project)
		pyQ = self.py_query()
		links = pyQ('a')
		projectUrl = self.project.url
		netloc = urlparse(projectUrl).netloc
		for link in links:
			if 'href' in link.attrib:
				href = link.attrib['href']
				href = resolve_url(href, projectUrl)
				path = base.filter(url=href) 
				if len(path) == 0:
					parsed = urlparse(href)
					if parsed.netloc == netloc:
						path = ApplicationPath(url=href)
						path.project=project
						path.user=user
						path.save()
Пример #4
0
	def py_query(self):
		if not hasattr(self, 'pyPath'):
			source = self.get_latest_source()
			self.pyPath = pyQ(source)
		return self.pyPath