Exemplo n.º 1
0
Arquivo: cli.py Projeto: Teifion/Rob3
def get_lore(options):
	from data_classes import lore_entry
	from lore import pages
	
	if len(sys.argv) < 3:
		print("Usage: $rob lore <cat> <page> <type:html/bbcode/plain>")
		exit()
	
	cursor = database.get_cursor()
	
	try:
		category = sys.argv[2]
		page = sys.argv[3]
		
		if len(sys.argv) > 4:
			formatting = sys.argv[4]
		else:
			formatting = "plaintext"
		
		if len(sys.argv) > 5:
			level = sys.argv[5].lower()
		else:
			level = "public"
	except Exception as e:
		raise
	
	if formatting == "html":
		print(pages.get_html(cursor, category, page, level))
	elif formatting == "bbcode":
		print(pages.get_bbcode(cursor, category, page, level))
	elif formatting == "plain" or formatting == "plaintext":
		print(pages.get_plaintext(cursor, category, page, level))
Exemplo n.º 2
0
def monster_info(cursor, cat, page, **kwargs):
	monster_name = kwargs.get("name", string.capwords(page))
	the_monster = monster_q.get_one_monster(cursor, monster_name)
	
	if the_monster == None:
		raise Exception("Could not find monster %s" % monster_name)
	
	source = pages.get_html(cursor, cat, page, level="public")
	output = []
	
	output.append("""
	<h1><a href="#top">{name}</a></h1>
	<!--Suggested men: {men}<br /> -->
	Approximate budget: {budget} materials<br />
	<!-- Habitat: {terrain}<br /> -->
	Expected amount: {amount}<br />
	<br />
	
	<strong>Eyewitness account:</strong><br />
	""".format(
		name = the_monster.name,
		budget = int((the_monster.min_budget * 2 + the_monster.max_budget)/3),
		men = int((the_monster.min_men * 2 + the_monster.max_men)/3),
		amount = int(the_monster.max_amount / 2),
		terrain = "",
	))
	
	output.append(source)
	
	return "".join(output)
	# return _wrap_template("".join(output), string.capwords(cat))
Exemplo n.º 3
0
Arquivo: lore.py Projeto: Teifion/Rob3
def main(cursor):
	cat		= common.get_val('cat', "")
	page	= common.get_val('page', "")
	
	page_data['title'] = "Lore: %s.%s" % (cat, page)
	
	try:
		output = pages.get_html(cursor, cat, page, "gm")
	except Exception as e:
		return str(e)
	
	return output
Exemplo n.º 4
0
def deity_info(cursor, cat, page, **kwargs):
	deity_name = kwargs.get("name", string.capwords(page))
	the_deity = deity_q.get_one_deity(cursor, deity_name)
	
	if the_deity == None:
		raise Exception("Could not find deity %s" % deity_name)
	
	source = pages.get_html(cursor, cat, page, level="public")
	output = []
	
	output.append("""
	<h1><a href="#top">{name}</a></h1>
	{summary}<br />
	<br />
	
	<strong>Major favour:</strong> {major}<br />
	<strong>Minor favour:</strong> {minor}<br />
	<strong>Negative favour:</strong> {negative}<br />
	<strong>Favour bonus:</strong> {bonus}<br />
	
	<strong>Dislikes:</strong> {dislikes}<br />
	<strong>Hates:</strong> {hates}<br />
	<br />
	
	<strong>Grand objective:</strong> {objective}<br />
	<strong>Divine intervention:</strong> {di}<br />
	<br /><br />
	
	<strong>Backstory:</strong><br />
	""".format(
		name = the_deity.name,
		summary = the_deity.summary,
		major = the_deity.major,
		minor = the_deity.minor,
		negative = the_deity.negative,
		bonus = the_deity.bonus,
		dislikes = the_deity.dislikes,
		hates = the_deity.hates,
		objective = the_deity.objective,
		di = the_deity.di,
	))
	output.append(source)
	
	return "".join(output)
	# return _wrap_template("".join(output), string.capwords(cat))
Exemplo n.º 5
0
	def test_html(self):
		data = pages.get_html(self.cursor, "test", "test", "public")
		self.assertEqual(data, "Summary text\n<br /><br />\nDescription <strong>text</strong> and more\n<br /><br />")
Exemplo n.º 6
0
def standard_page(cursor, cat, page, **kwargs):
    source = pages.get_html(cursor, cat, page, level="public")

    return source