示例#1
0
	def gotFeed(self, feed):
		if self.wrapper is not None:
			wrapper = self.wrapper(feed, self.ns)
		else:
			if feed.tag == "rss":
				self.wrapper = RSS2Wrapper
			elif feed.tag.startswith(NS_RDF):
				self.ns = NS_RDF
				self.wrapper = RSS1Wrapper
			elif feed.tag.startswith(NS_RSS_09):
				self.ns = NS_RSS_09
				self.wrapper = RSS1Wrapper
			elif feed.tag.startswith(NS_RSS_10):
				self.ns = NS_RSS_10
				self.wrapper = RSS1Wrapper
			elif feed.tag.endswith("feed"):
				self.wrapper = PEAWrapper
			else:
				raise NotImplementedError('Unsupported Feed: %s' % feed.tag)

			wrapper = self.wrapper(feed, self.ns)

			self.title = strip(wrapper.title) if PY3 else strip(wrapper.title).encode('utf-8')
			self.description = strip_readable(wrapper.description or "") if PY3 else strip_readable(wrapper.description or "").encode('utf-8')
			self.logoUrl = wrapper.logo

		return self.gotWrapper(wrapper)
示例#2
0
	def gotWrapper(self, wrapper):
		updated = wrapper.updated
		if updated and self.last_update == updated:
			return []

		idx = 0
		ids = self.last_ids
		for item in wrapper:
			# Try to read title, continue if none found
			title = strip(item.title if PY3 else item.title.encode('utf-8'))
			if not title:
				continue

			# Try to read id, continue if none found (invalid feed or internal error) or to be excluded
			id = item.id
			if not id or id in ids:
				continue

			# Link
			link = item.link if PY3 else item.link.encode('utf-8')

			# Try to read summary, empty if none
			summary = strip_readable(item.summary or "") if PY3 else strip_readable(item.summary or "").encode('utf-8')

			# Update Lists
			self.history.insert(idx, (title, link, summary, item.enclosures))
			ids.add(id)

			idx += 1

		# Eventually cut history
		del self.history[self.MAX_HISTORY_ELEMENTS:]

		return self.history[:idx]
示例#3
0
	def gotFeed(self, feed):
		if self.wrapper is not None:
			wrapper = self.wrapper(feed, self.ns)
		else:
			if feed.tag == "rss":
				self.wrapper = RSS2Wrapper
			elif feed.tag.startswith(NS_RDF):
				self.ns = NS_RDF
				self.wrapper = RSS1Wrapper
			elif feed.tag.startswith(NS_RSS_09):
				self.ns = NS_RSS_09
				self.wrapper = RSS1Wrapper
			elif feed.tag.startswith(NS_RSS_10):
				self.ns = NS_RSS_10
				self.wrapper = RSS1Wrapper
			elif feed.tag.endswith("feed"):
				self.wrapper = PEAWrapper
			else:
				raise NotImplementedError('Unsupported Feed: %s' % feed.tag)

			wrapper = self.wrapper(feed, self.ns)

			self.title = strip(wrapper.title).encode("UTF-8")
			self.description = strip_readable(wrapper.description or "").encode("UTF-8")
			self.logoUrl = wrapper.logo

		return self.gotWrapper(wrapper)
示例#4
0
    def reloadData(self, photo):
        if photo is None:
            return
        self.photo = photo
        unk = _("unknown")

        # camera
        if photo.exif.make and photo.exif.model:
            camera = '%s %s' % (photo.exif.make.text, photo.exif.model.text)
        elif photo.exif.make:
            camera = photo.exif.make.text
        elif photo.exif.model:
            camera = photo.exif.model.text
        else:
            camera = unk
        self['camera'].text = _("Camera: %s") % (camera, )

        title = photo.title.text.encode('utf-8') if photo.title.text else unk
        self.setTitle(_("eCasa: %s") % (title))
        self['title'].text = _("Title: %s") % (title, )
        summary = strip_readable(photo.summary.text).replace(
            '\n\nView Photo', '').encode('utf-8') if photo.summary.text else ''
        self['summary'].text = summary
        if photo.media and photo.media.keywords and photo.media.keywords.text:
            keywords = photo.media.keywords.text
            # TODO: find a better way to handle this
            if len(keywords) > 50:
                keywords = keywords[:47] + "..."
        else:
            keywords = unk
        self['keywords'].text = _("Keywords: %s") % (keywords, )

        try:
            real_w = int(photo.media.content[0].width)
            real_h = int(photo.media.content[0].heigth)
        except Exception as e:
            our_print(
                "EcasaPicture.__init__: illegal w/h values, using max size!")
            size = getDesktop(0).size()
            real_w = size.width()
            real_h = size.height()

        sc = AVSwitch().getFramebufferScale()
        self.picload.setPara(
            (real_w, real_h, sc[0], sc[1], False, 1, '#ff000000'))

        # NOTE: no need to start an extra thread for this, twisted is "parallel" enough in this case
        self.api.downloadPhoto(photo).addCallbacks(self.cbDownload,
                                                   self.ebDownload)
示例#5
0
	def reloadData(self, photo):
		if photo is None: return
		self.photo = photo
		unk = _("unknown")

		# camera
		if photo.exif.make and photo.exif.model:
			camera = '%s %s' % (photo.exif.make.text, photo.exif.model.text)
		elif photo.exif.make:
			camera = photo.exif.make.text
		elif photo.exif.model:
			camera = photo.exif.model.text
		else:
			camera = unk
		self['camera'].text = _("Camera: %s") % (camera,)

		title = photo.title.text.encode('utf-8') if photo.title.text else unk
		self.setTitle(_("eCasa: %s") % (title))
		self['title'].text = _("Title: %s") % (title,)
		summary = strip_readable(photo.summary.text).replace('\n\nView Photo', '').encode('utf-8') if photo.summary.text else ''
		self['summary'].text = summary
		if photo.media and photo.media.keywords and photo.media.keywords.text:
			keywords = photo.media.keywords.text
			# TODO: find a better way to handle this
			if len(keywords) > 50:
				keywords = keywords[:47] + "..."
		else:
			keywords = unk
		self['keywords'].text = _("Keywords: %s") % (keywords,)

		try:
			real_w = int(photo.media.content[0].width)
			real_h = int(photo.media.content[0].heigth)
		except Exception as e:
			our_print("EcasaPicture.__init__: illegal w/h values, using max size!")
			size = getDesktop(0).size()
			real_w = size.width()
			real_h = size.height()

		sc = AVSwitch().getFramebufferScale()
		self.picload.setPara((real_w, real_h, sc[0], sc[1], False, 1, '#ff000000'))

		# NOTE: no need to start an extra thread for this, twisted is "parallel" enough in this case
		self.api.downloadPhoto(photo).addCallbacks(self.cbDownload, self.ebDownload)
示例#6
0
	def gotWrapper(self, wrapper):
		updated = wrapper.updated
		if updated and self.last_update == updated:
			return []

		idx = 0
		ids = self.last_ids
		for item in wrapper:
			# Try to read title, continue if none found
			title = strip(item.title)
			if not title:
				continue

			# Try to read id, continue if none found (invalid feed or internal error) or to be excluded
			id = item.id
			if not id or id in ids:
				continue

			# Link
			link = item.link

			# Try to read summary, empty if none
			summary = strip_readable(item.summary or "")

			# Update Lists
			self.history.insert(idx, (
					title.encode("UTF-8"),
					link.encode("UTF-8"),
					summary.encode("UTF-8"),
					item.enclosures
			))
			ids.add(id)

			idx += 1

		# Eventually cut history
		del self.history[self.MAX_HISTORY_ELEMENTS:]

		return self.history[:idx]