def build_non_prominent_items_dict(k, v, data): npi_list = [] seen_here_list = loop_here(data, k, False, True) list_length = len(seen_here_list) if list_length > 1: for un in seen_here_list: unit_rec = data[un] if 'il' in unit_rec: item_list = unit_rec['il'] for items in range(0, len(item_list), 2): item_rec = data[item_list[items]] if 'IT' in item_rec and 'pr' in item_rec[ 'IT'] and item_rec['IT']['pr'][0] == '1': pass else: if int(item_list[items + 1]) > 0: weight = 0 qty = int(item_list[items + 1]) if 'wt' in item_rec['IT']: weight = int(item_rec['IT']['wt'][0]) total_weight = int(qty * weight) if total_weight > 0: npi_entry = { 'possessor_oid': to_oid(un), 'possessor_name': unit_rec['na'][0], 'item_oid': to_oid(item_list[items]), 'item_name': item_rec['na'][0], 'qty': qty, 'weight': total_weight } npi_list.append(npi_entry) return npi_list
def write_map_leaves(data, castle_chain, outdir, upperleft, height, width, prefix, instance): x_max = math.ceil(width / 10) y_max = math.ceil(height / 10) rem_height = height % 20 rem_width = width % 20 for outery in range(0, y_max): if outery < y_max - 1 or y_max == 1: startingpoint = upperleft + (outery * 1000) for outerx in range(0, x_max): if outerx < x_max - 1 or x_max == 1: currentpoint = startingpoint + (outerx * 10) printpoint = currentpoint # print('leaf {} ({})'.format(u.to_oid(printpoint), # prefix)) outf = open( pathlib.Path(outdir).joinpath(prefix + '_map_leaf_' + u.to_oid(printpoint) + '.html'), 'w') write_leaf_header(printpoint, outdir, prefix, outf) outf.write('<TABLE>\n') topnav = False botnav = False leftnav = False rightnav = False upperleftnav = False upperrightnav = False lowerleftnav = False lowerrightnav = False if currentpoint > upperleft + 99 and height > 20: topnav = True if rem_height > 0: if currentpoint < upperleft + ( (y_max - 2) * 1000) and height > 20: botnav = True else: if currentpoint < upperleft + ( (y_max - 2) * 1000) and height > 20: botnav = True y1 = (currentpoint - upperleft) % 100 if ((y1 % 10) > 1 or (y1 / 10) > 0) and width > 20: leftnav = True if topnav: upperleftnav = True if botnav: lowerleftnav = True if rem_width > 0 and width > 20: if (y1 % 10) > 1 or (y1 / 10) < (x_max - 2): rightnav = True else: if ((y1 % 10) > 1 or (y1 / 10) < (x_max - 2)) and width > 20: rightnav = True if rightnav: if topnav: upperrightnav = True if botnav: lowerrightnav = True if topnav: generate_topnav(currentpoint, outf, prefix, upperleftnav, upperrightnav) for y in range(0, 20): if (rem_height == 0 or outery <= y_max - 3) or \ (outery == y_max - 2 and y < rem_height + 10) or \ (y_max == 1 and y < rem_height): outf.write('<tr>\n') for x in range(0, 20): if (rem_width == 0 or outerx <= x_max - 3) or \ (outerx == x_max - 2 and x < rem_width + 10) or \ (x_max == 1 and x < rem_width): write_cell(castle_chain, currentpoint, data, leftnav, outf, prefix, rightnav, x, y, rem_width, rem_height, instance) outf.write('</tr>\n') if botnav: generate_botnav(currentpoint, lowerleftnav, lowerrightnav, outf, prefix) outf.write('</TABLE>\n') outf.write( '<a href="{}_map.html">Return to {} Map</a>'.format( prefix, prefix.capitalize())) outf.write('</BODY>\n') outf.write('</HTML>') outf.close()
def write_map_leaves(data, castle_chain, outdir, upperleft, height, width, prefix, instance, map_matrix): x_max = math.ceil(width / 10) y_max = math.ceil(height / 10) rem_height = height % 20 rem_width = width % 20 for outery in range(0, y_max): if outery < y_max - 1 or y_max == 1: for outerx in range(0, x_max): if outerx < x_max - 1 or x_max == 1: xx = outerx * 10 yy = outery * 10 currentpoint = map_matrix[yy][xx] printpoint = currentpoint # print('leaf {} ({})'.format(u.to_oid(printpoint), # prefix)) outf = open(pathlib.Path(outdir).joinpath(prefix + '_map_leaf_' + u.to_oid(printpoint) + '.html'), 'w') maps.write_leaf_header(printpoint, outdir, prefix, outf) outf.write('<TABLE>\n') topnav = False botnav = False leftnav = False rightnav = False upperleftnav = False upperrightnav = False lowerleftnav = False lowerrightnav = False if yy > 9 and height > 20: topnav = True if (height - yy) > 20 and height > 20: botnav = True if xx > 9 and width > 20: leftnav = True if topnav: upperleftnav = True if botnav: lowerleftnav = True if (width - xx) > 20 and width > 20: rightnav = True if rightnav: if topnav: upperrightnav = True if botnav: lowerrightnav = True if topnav: generate_topnav(currentpoint, outf, prefix, upperleftnav, upperrightnav, xx, yy, map_matrix) for y in range(0, 20): if yy + y < height: outf.write('<tr>\n') for x in range(0, 20): if xx + x < width: write_cell(castle_chain, currentpoint, data, leftnav, outf, prefix, rightnav, x, y, xx, yy, instance, map_matrix) outf.write('</tr>\n') if botnav: generate_botnav(currentpoint, lowerleftnav, lowerrightnav, outf, prefix, xx, yy, map_matrix) outf.write('</TABLE>\n') outf.write('<a href="{}_map.html">Return to {} Map</a>'.format(prefix, prefix.capitalize())) outf.write('</BODY>\n') outf.write('</HTML>') outf.close()
def write_legacy_map_leaves(data, castle_chain, outdir, upperleft, height, width, prefix, instance, map_matrix): x_max = math.ceil(width / 10) y_max = math.ceil(height / 10) rem_height = height % 20 rem_width = width % 20 for outery in range(0, y_max): if outery < y_max - 1 or y_max == 1: for outerx in range(0, x_max): if outerx < x_max - 1 or x_max == 1: xx = outerx * 10 yy = outery * 10 currentpoint = map_matrix[yy][xx] printpoint = currentpoint # print('leaf {} ({})'.format(u.to_oid(printpoint), # prefix)) outf = open( pathlib.Path(outdir).joinpath(prefix + '_map_leaf_' + u.to_oid(printpoint) + '.html'), 'w') topnav = False botnav = False leftnav = False rightnav = False upperleftnav = False upperrightnav = False lowerleftnav = False lowerrightnav = False if yy > 9 and height > 20: topnav = True if (height - yy) > 20 and height > 20: botnav = True if xx > 9 and width > 20: leftnav = True if topnav: upperleftnav = True if botnav: lowerleftnav = True if (width - xx) > 20 and width > 20: rightnav = True if rightnav: if topnav: upperrightnav = True if botnav: lowerrightnav = True top_nav_dict = {} if topnav: top_nav_dict = generate_topnav(currentpoint, outf, prefix, upperleftnav, upperrightnav, xx, yy, map_matrix) cell_list = [] row_list = [] for y in range(0, 20): if yy + y < height: for x in range(0, 20): if xx + x < width: cell_dict = write_cell( castle_chain, currentpoint, data, leftnav, outf, prefix, rightnav, x, y, xx, yy, instance, map_matrix) cell_list.append(cell_dict) row_list.append(cell_list) cell_list = [] bot_nav_dict = {} if botnav: bot_nav_dict = generate_botnav(currentpoint, lowerleftnav, lowerrightnav, outf, prefix, xx, yy, map_matrix) map_dict = { 'prefix': prefix, 'prefix_title': prefix.title(), 'oid': to_oid(printpoint), 'top': topnav, 'bot': botnav, 'left': leftnav, 'right': rightnav, 'topnav_dict': top_nav_dict, 'botnav_dict': bot_nav_dict, 'row_list': row_list } outf = open( pathlib.Path(outdir).joinpath(prefix + '_map_leaf_' + u.to_oid(printpoint) + '.html'), 'w') template = olymap.env.get_template('map_leaf.html') outf.write(template.render(map=map_dict))
def write_map_leaves(data, castle_chain, outdir, upperleft, height, width, prefix, instance): x_max = math.ceil(width / 10) y_max = math.ceil(height / 10) rem_height = height % 20 rem_width = width % 20 for outery in range(0, y_max): if outery < y_max - 1 or y_max == 1: startingpoint = upperleft + (outery * 1000) for outerx in range(0, x_max): if outerx < x_max - 1 or x_max == 1: currentpoint = startingpoint + (outerx * 10) printpoint = currentpoint # print('leaf {} ({})'.format(u.to_oid(printpoint), # prefix)) outf = open( pathlib.Path(outdir).joinpath(prefix + '_map_leaf_' + u.to_oid(printpoint) + '.html'), 'w') topnav = False botnav = False leftnav = False rightnav = False upperleftnav = False upperrightnav = False lowerleftnav = False lowerrightnav = False if currentpoint > upperleft + 99 and height > 20: topnav = True if rem_height > 0: if currentpoint < upperleft + ( (y_max - 2) * 1000) and height > 20: botnav = True else: if currentpoint < upperleft + ( (y_max - 2) * 1000) and height > 20: botnav = True y1 = (currentpoint - upperleft) % 100 if ((y1 % 10) > 1 or (y1 / 10) > 0) and width > 20: leftnav = True if topnav: upperleftnav = True if botnav: lowerleftnav = True if rem_width > 0 and width > 20: if (y1 % 10) > 1 or (y1 / 10) < (x_max - 2): rightnav = True else: if ((y1 % 10) > 1 or (y1 / 10) < (x_max - 2)) and width > 20: rightnav = True if rightnav: if topnav: upperrightnav = True if botnav: lowerrightnav = True top_nav_dict = {} if topnav: top_nav_dict = generate_topnav(currentpoint, outf, prefix, upperleftnav, upperrightnav) cell_list = [] row_list = [] for y in range(0, 20): if (rem_height == 0 or outery <= y_max - 3) or \ (outery == y_max - 2 and y < rem_height + 10) or \ (y_max == 1 and y < rem_height): for x in range(0, 20): if (rem_width == 0 or outerx <= x_max - 3) or \ (outerx == x_max - 2 and x < rem_width + 10) or \ (x_max == 1 and x < rem_width): cell_dict = write_cell( castle_chain, currentpoint, data, leftnav, outf, prefix, rightnav, x, y, rem_width, rem_height, instance) cell_list.append(cell_dict) row_list.append(cell_list) cell_list = [] bot_nav_dict = {} if botnav: bot_nav_dict = generate_botnav(currentpoint, lowerleftnav, lowerrightnav, outf, prefix) map_dict = { 'prefix': prefix, 'prefix_title': prefix.title(), 'oid': to_oid(printpoint), 'top': topnav, 'bot': botnav, 'left': leftnav, 'right': rightnav, 'topnav_dict': top_nav_dict, 'botnav_dict': bot_nav_dict, 'row_list': row_list } outf = open( pathlib.Path(outdir).joinpath(prefix + '_map_leaf_' + u.to_oid(printpoint) + '.html'), 'w') template = olymap.env.get_template('map_leaf.html') outf.write(template.render(map=map_dict))