Ejemplo n.º 1
0
	def parse_logbook_item(self, parameter):
		# json.loads() returns unicode, thus convert strings and compare to unicode
		# Image works with str() since pychan can only use str objects as file path
		if parameter and parameter[0]: # allow empty Labels
			parameter_type = parameter[0]
		if isinstance(parameter, basestring):
			add = Label(text=unicode(parameter), wrap_text=True, min_size=(335, 0), max_size=(335, 508))
		elif parameter_type == u'Label':
			add = Label(text=unicode(parameter[1]), wrap_text=True, min_size=(335, 0), max_size=(335, 508))
		elif parameter_type == u'Image':
			add = Icon(image=str(parameter[1]))
		elif parameter_type == u'Gallery':
			add = HBox()
			for image in parameter[1]:
				add.addChild(Icon(image=str(image)))
		elif parameter_type == u'Headline':
			add = Label(text=parameter[1])
			add.stylize('headline')
		elif parameter_type == u'Message':
			add = None
			# parameters are re-read on page reload.
			# duplicate_message stops messages from
			# being duplicated on page reload.
			duplicate_message = parameter[1] in self._messages

			if not duplicate_message:
				self._messages[parameter[1]] = False # has not been displayed
		else:
			print '[WW] Warning: Unknown parameter type {typ} in parameter {prm}'.format(
				typ=parameter[0], prm=parameter)
			add = None
		self.log.debug("parameter added of type %s", parameter_type)
		return add
Ejemplo n.º 2
0
    def parse_logbook_item(self, parameter):
        # json.loads() returns unicode, thus convert strings and compare to unicode
        # Image works with str() since pychan can only use str objects as file path
        if parameter and parameter[0]:  # allow empty Labels
            parameter_type = parameter[0]
        if isinstance(parameter, basestring):
            add = Label(text=unicode(parameter),
                        wrap_text=True,
                        min_size=(335, 0),
                        max_size=(335, 508))
        elif parameter_type == u'Label':
            add = Label(text=unicode(parameter[1]),
                        wrap_text=True,
                        min_size=(335, 0),
                        max_size=(335, 508))
        elif parameter_type == u'Image':
            add = Icon(image=str(parameter[1]))
        elif parameter_type == u'Gallery':
            add = HBox()
            for image in parameter[1]:
                add.addChild(Icon(image=str(image)))
        elif parameter_type == u'Headline':
            add = Label(text=unicode(parameter[1]),
                        wrap_text=True,
                        min_size=(335, 0),
                        max_size=(335, 508),
                        font='headline')
        elif parameter_type == u'BoldLabel':
            add = Label(text=unicode(parameter[1]),
                        wrap_text=True,
                        min_size=(335, 0),
                        max_size=(335, 508),
                        font='14_bold')
        elif parameter_type == u'Message':
            add = None
            # parameters are re-read on page reload.
            # duplicate_message stops messages from
            # being duplicated on page reload.
            message = parameter[1]
            duplicate_message = message in self._messages_to_display  # message is already going to be displayed

            if not duplicate_message:
                self._messages_to_display.append(
                    message)  # the new message has not been displayed
        else:
            print '[WW] Warning: Unknown parameter type {typ} in parameter {prm}'.format(
                typ=parameter[0], prm=parameter)
            add = None
        return add
Ejemplo n.º 3
0
	def parse_logbook_item(self, widget):
		# json.loads() returns unicode, thus convert strings and compare to unicode
		# Image works with str() since pychan can only use str objects as file path
		if widget and widget[0]: # allow empty Labels
			widget_type = widget[0]
		if isinstance(widget, basestring):
			add = Label(text=widget, wrap_text=True, max_size=(340,508))
		elif widget_type == u'Label':
			add = Label(text=widget[1], wrap_text=True, max_size=(340,508))
		elif widget_type == u'Image':
			add = Icon(image=str(widget[1]))
		elif widget_type == u'Gallery':
			add = HBox()
			for image in widget[1]:
				add.addChild(Icon(image=str(image)))
		elif widget_type == u'Headline':
			add = Label(text=widget[1])
			add.stylize('headline')
		else:
			print '[WW] Warning: Unknown widget type {typ} in widget {wdg}'.format(
				typ=widget[0], wdg=widget)
			add = None
		return add
Ejemplo n.º 4
0
	def parse_logbook_item(self, parameter):
		# json.loads() returns unicode, thus convert strings and compare to unicode
		# Image works with str() since pychan can only use str objects as file path
		if parameter and parameter[0]: # allow empty Labels
			parameter_type = parameter[0]
		if isinstance(parameter, basestring):
			add = Label(text=unicode(parameter), wrap_text=True, min_size=(335, 0), max_size=(335, 508))
		elif parameter_type == u'Label':
			add = Label(text=unicode(parameter[1]), wrap_text=True, min_size=(335, 0), max_size=(335, 508))
		elif parameter_type == u'Image':
			add = Icon(image=str(parameter[1]))
		elif parameter_type == u'Gallery':
			add = HBox()
			for image in parameter[1]:
				add.addChild(Icon(image=str(image)))
		elif parameter_type == u'Headline':
			add = Label(text=unicode(parameter[1]), wrap_text=True,
			            min_size=(335, 0), max_size=(335, 508), font='headline')
		elif parameter_type == u'BoldLabel':
			add = Label(text=unicode(parameter[1]), wrap_text=True,
			            min_size=(335, 0), max_size=(335, 508), font='14_bold')
		elif parameter_type == u'Message':
			add = None
			# parameters are re-read on page reload.
			# duplicate_message stops messages from
			# being duplicated on page reload.
			message = parameter[1]
			duplicate_message = message in self._messages_to_display # message is already going to be displayed

			if not duplicate_message:
				self._messages_to_display.append(message) # the new message has not been displayed
		else:
			print '[WW] Warning: Unknown parameter type {typ} in parameter {prm}'.format(
				typ=parameter[0], prm=parameter)
			add = None
		return add