import re, fileinput, sys
import utilities as u
import os
import ast
# block_id is a global variable that is used to keep track of the current block id
block_id = 0
# This function takes in the user input and block_id and returns a list of blocks built with textareas
def build_blocks(user_input, block_id):
list_of_blocks = []
title_block = build_title_block(user_input['store_name'], user_input['store_description'], user_input['store_backstory'], user_input['store_reputation'])
block_id = block_id + 1
list_of_blocks.append(title_block)
store_image_block = build_image_block(user_input['storefront_sd_prompt'], block_id)
block_id = block_id + 1
list_of_blocks.append(store_image_block)
store_properties_block = build_store_properties_block(store_type= user_input['store_type'],
store_size= user_input['store_size'],
store_hours= user_input['store_hours'],
store_location= user_input['store_location'],
store_owners= user_input['store_owners'],
store_employees= user_input['store_employees'],
store_services= user_input['store_services'],
store_specialties= user_input['store_specialties'],
store_reputation= user_input['store_reputation'],
store_rumors= user_input['store_rumors'],
block_id= block_id)
block_id = block_id + 1
list_of_blocks.append(store_properties_block)
owner_id = 1
# Iterate over owners and generate owner image and details block
owner_title = "Owner"
if len(user_input['store_owners']) > 1:
owner_title = "Owners"
owner_title_block = f"""
{owner_title}
"""
for owner in user_input['store_owners']:
owner_image_block = build_image_block(owner['sd_prompt'], block_id)
block_id = block_id + 1
list_of_blocks.append(owner_image_block)
owner_block = build_owner_block(owner,owner_id, owner_title_block, block_id)
block_id = block_id + 1
list_of_blocks.append(owner_block)
owner_id += 1
employee_id = 1
# Iterate over employees and generate employee image and details block
employee_title = "Employee"
if len(user_input['store_employees']) > 1:
employee_title = "Employees"
employee_title_block = f"""
{employee_title}
"""
for employee in user_input['store_employees']:
employee_image_block = build_image_block(employee['sd_prompt'], block_id)
block_id = block_id + 1
list_of_blocks.append(employee_image_block)
employee_block = build_employee_block(employee, employee_id, employee_title_block, block_id)
block_id = block_id + 1
list_of_blocks.append(employee_block)
employee_id += 1
return list_of_blocks
# Take in a specific item type and item, and return the html for that item
def process_into_html(item_type,item, block_id):
item_html = f"""
{item_type}
"""
return item_html
# Take in a specific iterable type and iterable, and return the html for that iterable
def process_iterable_into_html(iterable_type, iterable, block_id):
iterable_html = f""""""
for item in iterable:
item_html = f"""
{iterable_type}
"""
iterable_html += item_html
return iterable_html
# Take in a list of rumors and return the html for that list of rumors
def process_rumors_into_html(rumors, block_id):
rumors_html = f""""""
for rumor in rumors:
rumor_html = f"""
Store Rumors
"""
rumors_html += rumor_html
return rumors_html
# Take in a list of secrets and return the html for that list of secrets
def process_secrets_into_html(secrets, block_id):
secrets_html = f""""""
for secret in secrets:
secret_html = f"""
Secrets
"""
secrets_html += secret_html
return secrets_html
# Block for title, description, backstory, and reputation
def build_title_block(title,description,backstory,reputation):
title_block_html = f"""
"""
return image_block_html
# Block for store properties
def build_store_properties_block(store_type,
store_size,
store_hours,
store_location,
store_owners,
store_employees,
store_services,
store_specialties,
store_reputation,
store_rumors,
block_id):
# This could be a function since each block is identical.
store_properties_base_html = f"""