Esempio n. 1
0
 def get_document(self, path):
     import quotes
     style, mapping = quotes.get_quotes()
     return style
Esempio n. 2
0
	def get_document(self, path):
		import quotes
		style, mapping = quotes.get_quotes()
		return style
Esempio n. 3
0
	def start_q(self, tag):
		style, quote_mapping = quotes.get_quotes()
		#print "Q", tag.toString()
		type      = tag.getAttribute("type");
		who       = tag.getAttribute("who");
		tmp		  = tag.getAttribute("level");
		level	  = int(tmp) if tmp else 1
		mark      = tag.getAttribute("marker");
		# open <q> or <q sID... />
		if ((not tag.isEmpty() and not tag.isEndTag()) or (tag.isEmpty() and tag.getAttribute("sID"))):
			# if <q> then remember it for the </q>
			if not tag.isEmpty():
				self._quotes.append(tag.toString())

			# Do this first so quote marks are included as WoC
			if (who == "Jesus"):
				self.write("<span class='WoC'>")

			# first check to see if we've been given an explicit mark
			if mark is not None:
				self.write(mark)
			
			# alternate " and '
			elif (self.u.osisQToTick):
				self.write('"' if (level % 2) else '\'')
		
			if tag.getAttribute("sID"):
				qID = tag.getAttribute("sID").replace(".", "_")
				d = quote_mapping.get(qID, "")
				if not d:
					dprint(WARNING, "No who found for qID", qID)

				self.write_quote(qID, d, True)
				self._quotes_data.append((qID, d))
			else:
				#print "non-sid Start", tag.toString()
				pass
				
		# close </q> or <q eID... />
		elif ((tag.isEndTag()) or (tag.isEmpty() and tag.getAttribute("eID"))):
			# if it is </q> then pop the stack for the attributes
			if (tag.isEndTag() and self._quotes):
				tagData  = self._quotes.pop()
				qTag = SW.XMLTag(tagData)

				type    = qTag.getAttribute("type");
				who     = qTag.getAttribute("who");
				tmp     = qTag.getAttribute("level");
				level   = int(tmp) if tmp else 1
				mark    = qTag.getAttribute("marker");

			qID = tag.getAttribute("eID")
			if qID:
				qID = qID.replace(".", "_")
			
				if not self._quotes_data:
					dprint(ERROR, "Quotes data empty", qID,
					self.u.key.getText())

				else:
					d = self._quotes_data.pop()
					if d[0] != qID:
						dprint(ERROR, "Mismatching closing quotes", d, qID)

					self.write_quote(d[0], d[1], False)
			#else:
			#	print tag.toString()

			# first check to see if we've been given an explicit mark
			if mark is not None:
				self.write(mark)

			# finally, alternate " and ', if config says we should supply a mark
			elif (self.u.osisQToTick):
				self.write('"' if (level % 2) else '\'')

			# Do this last so quote marks are included as WoC
			if (who == "Jesus"):
				self.write("</span>")
Esempio n. 4
0
QOS = 0


def on_connect(client, userdata, flags, rc):
    print("Connected with result code " + str(rc))


def on_disconnect(client, userdata, rc):
    print("Disconnected")
    time.sleep(5)


def on_publish(client, userdata, mid):
    print("Message published")


client = paho.Client(protocol=paho.MQTTv31)
#client = paho.Client(client_id="foogoo", clean_session=True, userdata=None, protocol=paho.MQTTv31)

client.on_connect = on_connect
client.on_disconnect = on_disconnect
client.on_publish = on_publish

client.connect("localhost", 1883, 60)
client.loop_start()

while True:
    message = get_quotes()
    (rc, mid) = client.publish("quotes", message, qos=QOS)
    time.sleep(3)