Files for the publication & poster for Data Workers, an exhibition by Algolit. http://www.algolit.net/index.php/Data_Workers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.2 KiB

6 years ago
from functions import insert_linebreaks, insert_text_block
from create_inserted_header import insert_header
import math
def create_columns(string, column_count, page_height):
print('--- start create_columns() ---')
print('>>> column_count:', column_count)
# column_width = int(113/column_count)
column_width = 28
string = string.replace(': ', '\n') # Insert linebreaks for legibility
string = insert_linebreaks(string, column_width-4, type='word')
# Double check the linebreaks
lines = string.split('\n')
all_lines = []
for line in lines:
if len(line) > column_width - 1:
line = insert_linebreaks(line, column_width-8, type='word')
all_lines.append(line)
lines = all_lines
total_number_of_columns = math.ceil(len(lines)/page_height)
number_of_pages = total_number_of_columns/column_count
print('>>> number_of_pages:', number_of_pages)
print('>>> total_number_of_columns:', total_number_of_columns)
pages = ''
columns_string = ''
columns = []
current_column = 1
for num in range(0, total_number_of_columns):
# print('>>> current column:', num)
columns.append([])
current_start = num * page_height
current_end = current_start + page_height
# print('>>> current start/end:', current_start, current_end)
current_line_range = lines[current_start:current_end]
# print('>>> line range:', current_line_range)
line_count = 1
for l, line in enumerate(current_line_range):
if '* ' in line:
columns[num].append(line.upper())
line_count += 1
elif line_count <= page_height:
columns[num].append(' ' + line)
line_count += 1
if num == 0:
columns_string = '\n'.join(columns[num]) # Start of a new column string
current_column += 1
elif num % column_count == 0:
pages += insert_header(columns_string) + '\n' # Append new page
columns_string = '\n'.join(columns[num]) # Start of a new column string
current_column = 2
line_count = 1
else:
left = (column_width + 0) * (current_column - 1)
new_column = '\n'.join(columns[num])
columns_string = insert_text_block(columns_string, new_column, left, 25)
current_column += 1
pages += insert_header(columns_string) # Append new page
print('--- end create_columns() ---')
return pages
def create_glossary(string):
return create_columns(string, 4, 63)