Browse Source

switching off some print statements

master
manetta 2 years ago
parent
commit
ab39fea373
  1. 33
      command-line/update.py

33
command-line/update.py

@ -4,6 +4,8 @@ import re
import json
import jinja2
# Notes are here: https://pad.vvvvvvaria.org/volumetric-regimes-in-process.
STATIC_FOLDER_PATH = '.' # without trailing slash
PUBLIC_STATIC_FOLDER_PATH = '.' # without trailing slash
TEMPLATES_DIR = './templates'
@ -93,20 +95,12 @@ def download_media(html, images, wiki):
img_path_patterns = [rf'(?<!\.)/images/.*?px-{ filename }', rf'(?<!\.)/images/.*?{ filename }']
for img_path_pattern in img_path_patterns:
matches = re.findall(img_path_pattern, html) # for debugging
# print(f'{ filename }\n')
if matches:
for match in matches:
if match not in replaced:
# print(f' { match } --> { image_path }') # for debugging: each image should have the correct match!
html = html.replace(match, image_path)
replaced.append(match)
# else:
# print(' already replaced!')
# print('\n------\n')
# break
# else:
# print(' no match!')
# print('\n------\n')
return html
@ -119,10 +113,10 @@ def add_item_inventory_links(html):
matches = re.findall(r'\w.*?Item \d\d\d.*?\w\w\w', html) # Dodgy attempt to find unique patterns for each mentioning of Item ###
index = {}
for match in matches:
item_match = re.search(r'Item \d\d\d', match)
item = item_match.group()
number = item.replace('Item ', '').strip()
text = match.replace(f'Item { number }', '')
item_match = re.search(r'Item \d\d\d', match).group()
number = item_match.replace('Item ', '').strip()
text_before = re.search(rf'\w.*?Item { number }', match).group().replace(f'Item { number }', '')
text_after = re.search(rf'Item { number }.*?\w\w\w', match).group().replace(f'Item { number }', '')
if not number in index:
index[number] = []
count = 1
@ -130,8 +124,8 @@ def add_item_inventory_links(html):
count = index[number][-1] + 1
index[number].append(count)
item_id = f'ii-{ number }-{ index[number][-1] }'
print(f'match: { number } --> { item_id } --> { text }')
html = html.replace(match, f'<a id="{ item_id }" href="#Item_Index">Item { number }</a>{ text }')
# print(f'match: { number } --> { item_id } --> { match }')
html = html.replace(match, f'{ text_before }<a id="{ item_id }" href="#Item_Index">Item { number }</a>{ text_after }')
# IN THE ITEM INDEX
# Also add a <span> around the index nr to style it
@ -209,17 +203,6 @@ def tweaking(html):
for match in results:
html = html.replace(match, f'<div class="title-wrapper">{ match }</div>')
# for result in results:
# print(result)
# print('---')
# print('---')
# print('AANTAL:', len(results))
# print('SET LEN:', len(set(results)))
# print('---')
# html = html.replace('<div class="multi"></div>', f'<div class="multi"><img src="{ PUBLIC_STATIC_FOLDER_PATH }/images/multi-remix.svg"></div>') # add Multi Remix as SVG
# html = html.replace('', '')
return html
def clean_up(html):

Loading…
Cancel
Save