You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

452 lines
16 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"quilt = [\n",
"[\"2-louisa-final\",\"Camilo\",\"newest patch_floor_rain\",\"jacopo.otherness.def\"],\n",
"[\"kendalpatch\",\"euna\", \"patchericoforthefuture\",\"punctuationflag\"],\n",
"[\"euna\",\"punctuationflag\",\"euna\",\"patchericoforthefuture\"],\n",
"[\"2-louisa-final\",\"MARTIN_GRADIENTENSE\", \"jacopo.otherness.def\",\"kendalpatch\"],\n",
"]\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[['2-louisa-final',\n",
" 'Camilo',\n",
" 'newest patch_floor_rain',\n",
" 'jacopo.otherness.def'],\n",
" ['kendalpatch', 'euna', 'patchericoforthefuture', 'punctuationflag'],\n",
" ['euna', 'punctuationflag', 'euna', 'patchericoforthefuture'],\n",
" ['2-louisa-final',\n",
" 'MARTIN_GRADIENTENSE',\n",
" 'jacopo.otherness.def',\n",
" 'kendalpatch']]"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"quilt"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"line 0 2-louisa-final\n",
"line 0 Camilo\n",
"line 0 newest patch_floor_rain\n",
"line 0 jacopo.otherness.def\n",
"line 1 2-louisa-final\n",
"line 1 Camilo\n",
"line 1 newest patch_floor_rain\n",
"line 1 jacopo.otherness.def\n",
"line 2 2-louisa-final\n",
"line 2 Camilo\n",
"line 2 newest patch_floor_rain\n",
"line 2 jacopo.otherness.def\n",
"line 3 2-louisa-final\n",
"line 3 Camilo\n",
"line 3 newest patch_floor_rain\n",
"line 3 jacopo.otherness.def\n",
"line 4 2-louisa-final\n",
"line 4 Camilo\n",
"line 4 newest patch_floor_rain\n",
"line 4 jacopo.otherness.def\n",
"line 5 2-louisa-final\n",
"line 5 Camilo\n",
"line 5 newest patch_floor_rain\n",
"line 5 jacopo.otherness.def\n",
"line 6 2-louisa-final\n",
"line 6 Camilo\n",
"line 6 newest patch_floor_rain\n",
"line 6 jacopo.otherness.def\n",
"line 7 2-louisa-final\n",
"line 7 Camilo\n",
"line 7 newest patch_floor_rain\n",
"line 7 jacopo.otherness.def\n",
"line 8 2-louisa-final\n",
"line 8 Camilo\n",
"line 8 newest patch_floor_rain\n",
"line 8 jacopo.otherness.def\n",
"line 9 2-louisa-final\n",
"line 9 Camilo\n",
"line 9 newest patch_floor_rain\n",
"line 9 jacopo.otherness.def\n",
"line 10 2-louisa-final\n",
"line 10 Camilo\n",
"line 10 newest patch_floor_rain\n",
"line 10 jacopo.otherness.def\n",
"line 11 2-louisa-final\n",
"line 11 Camilo\n",
"line 11 newest patch_floor_rain\n",
"line 11 jacopo.otherness.def\n",
"line 12 2-louisa-final\n",
"line 12 Camilo\n",
"line 12 newest patch_floor_rain\n",
"line 12 jacopo.otherness.def\n",
"line 13 2-louisa-final\n",
"line 13 Camilo\n",
"line 13 newest patch_floor_rain\n",
"line 13 jacopo.otherness.def\n",
"line 14 2-louisa-final\n",
"line 14 Camilo\n",
"line 14 newest patch_floor_rain\n",
"line 14 jacopo.otherness.def\n",
"line 15 2-louisa-final\n",
"line 15 Camilo\n",
"line 15 newest patch_floor_rain\n",
"line 15 jacopo.otherness.def\n",
"line 16 2-louisa-final\n",
"line 16 Camilo\n",
"line 16 newest patch_floor_rain\n",
"line 16 jacopo.otherness.def\n",
"line 17 2-louisa-final\n",
"line 17 Camilo\n",
"line 17 newest patch_floor_rain\n",
"line 17 jacopo.otherness.def\n",
"line 18 2-louisa-final\n",
"line 18 Camilo\n",
"line 18 newest patch_floor_rain\n",
"line 18 jacopo.otherness.def\n",
"line 19 2-louisa-final\n",
"line 19 Camilo\n",
"line 19 newest patch_floor_rain\n",
"line 19 jacopo.otherness.def\n",
"line 20 2-louisa-final\n",
"line 20 Camilo\n",
"line 20 newest patch_floor_rain\n",
"line 20 jacopo.otherness.def\n",
"line 21 2-louisa-final\n",
"line 21 Camilo\n",
"line 21 newest patch_floor_rain\n",
"line 21 jacopo.otherness.def\n",
"line 22 2-louisa-final\n",
"line 22 Camilo\n",
"line 22 newest patch_floor_rain\n",
"line 22 jacopo.otherness.def\n",
"line 23 2-louisa-final\n",
"line 23 Camilo\n",
"line 23 newest patch_floor_rain\n",
"line 23 jacopo.otherness.def\n",
"line 24 2-louisa-final\n",
"line 24 Camilo\n",
"line 24 newest patch_floor_rain\n",
"line 24 jacopo.otherness.def\n",
"line 25 2-louisa-final\n",
"line 25 Camilo\n",
"line 25 newest patch_floor_rain\n",
"line 25 jacopo.otherness.def\n",
"line 26 2-louisa-final\n",
"line 26 Camilo\n",
"line 26 newest patch_floor_rain\n",
"line 26 jacopo.otherness.def\n",
"line 27 2-louisa-final\n",
"line 27 Camilo\n",
"line 27 newest patch_floor_rain\n",
"line 27 jacopo.otherness.def\n",
"line 28 2-louisa-final\n",
"line 28 Camilo\n",
"line 28 newest patch_floor_rain\n",
"line 28 jacopo.otherness.def\n",
"line 29 2-louisa-final\n",
"line 29 Camilo\n",
"line 29 newest patch_floor_rain\n",
"line 29 jacopo.otherness.def\n",
"line 30 2-louisa-final\n",
"line 30 Camilo\n",
"line 30 newest patch_floor_rain\n",
"line 30 jacopo.otherness.def\n",
"line 31 2-louisa-final\n",
"line 31 Camilo\n",
"line 31 newest patch_floor_rain\n",
"line 31 jacopo.otherness.def\n",
"line 32 2-louisa-final\n",
"line 32 Camilo\n",
"line 32 newest patch_floor_rain\n",
"line 32 jacopo.otherness.def\n",
"line 33 2-louisa-final\n",
"line 33 Camilo\n",
"line 33 newest patch_floor_rain\n",
"line 33 jacopo.otherness.def\n",
"line 34 2-louisa-final\n",
"line 34 Camilo\n",
"line 34 newest patch_floor_rain\n",
"line 34 jacopo.otherness.def\n",
"line 35 2-louisa-final\n",
"line 35 Camilo\n",
"line 35 newest patch_floor_rain\n",
"line 35 jacopo.otherness.def\n",
"line 36 2-louisa-final\n",
"line 36 Camilo\n",
"line 36 newest patch_floor_rain\n",
"line 36 jacopo.otherness.def\n",
"line 37 2-louisa-final\n",
"line 37 Camilo\n",
"line 37 newest patch_floor_rain\n",
"line 37 jacopo.otherness.def\n",
"line 38 2-louisa-final\n",
"line 38 Camilo\n",
"line 38 newest patch_floor_rain\n",
"line 38 jacopo.otherness.def\n",
"line 39 2-louisa-final\n",
"line 39 Camilo\n",
"line 39 newest patch_floor_rain\n",
"line 39 jacopo.otherness.def\n",
"line 40 2-louisa-final\n",
"line 40 Camilo\n",
"line 40 newest patch_floor_rain\n",
"line 40 jacopo.otherness.def\n",
"line 41 2-louisa-final\n",
"line 41 Camilo\n",
"line 41 newest patch_floor_rain\n",
"line 41 jacopo.otherness.def\n",
"line 42 2-louisa-final\n",
"line 42 Camilo\n",
"line 42 newest patch_floor_rain\n",
"line 42 jacopo.otherness.def\n",
"line 43 2-louisa-final\n",
"line 43 Camilo\n",
"line 43 newest patch_floor_rain\n",
"line 43 jacopo.otherness.def\n",
"line 44 2-louisa-final\n",
"line 44 Camilo\n",
"line 44 newest patch_floor_rain\n",
"line 44 jacopo.otherness.def\n",
"line 45 2-louisa-final\n",
"line 45 Camilo\n",
"line 45 newest patch_floor_rain\n",
"line 45 jacopo.otherness.def\n",
"line 46 2-louisa-final\n",
"line 46 Camilo\n",
"line 46 newest patch_floor_rain\n",
"line 46 jacopo.otherness.def\n",
"line 47 2-louisa-final\n",
"line 47 Camilo\n",
"line 47 newest patch_floor_rain\n",
"line 47 jacopo.otherness.def\n",
"line 48 2-louisa-final\n",
"line 48 Camilo\n",
"line 48 newest patch_floor_rain\n",
"line 48 jacopo.otherness.def\n",
"line 49 2-louisa-final\n",
"line 49 Camilo\n",
"line 49 newest patch_floor_rain\n",
"line 49 jacopo.otherness.def\n",
"line 50 2-louisa-final\n",
"line 50 Camilo\n",
"line 50 newest patch_floor_rain\n",
"line 50 jacopo.otherness.def\n",
"line 51 2-louisa-final\n",
"line 51 Camilo\n",
"line 51 newest patch_floor_rain\n",
"line 51 jacopo.otherness.def\n",
"line 52 2-louisa-final\n",
"line 52 Camilo\n",
"line 52 newest patch_floor_rain\n",
"line 52 jacopo.otherness.def\n",
"line 53 2-louisa-final\n",
"line 53 Camilo\n",
"line 53 newest patch_floor_rain\n",
"line 53 jacopo.otherness.def\n",
"line 54 2-louisa-final\n",
"line 54 Camilo\n",
"line 54 newest patch_floor_rain\n",
"line 54 jacopo.otherness.def\n",
"line 55 2-louisa-final\n",
"line 55 Camilo\n",
"line 55 newest patch_floor_rain\n",
"line 55 jacopo.otherness.def\n",
"line 56 2-louisa-final\n",
"line 56 Camilo\n",
"line 56 newest patch_floor_rain\n",
"line 56 jacopo.otherness.def\n",
"line 57 2-louisa-final\n",
"line 57 Camilo\n",
"line 57 newest patch_floor_rain\n",
"line 57 jacopo.otherness.def\n",
"line 58 2-louisa-final\n",
"line 58 Camilo\n",
"line 58 newest patch_floor_rain\n",
"line 58 jacopo.otherness.def\n",
"line 59 2-louisa-final\n",
"line 59 Camilo\n",
"line 59 newest patch_floor_rain\n",
"line 59 jacopo.otherness.def\n",
"line 60 2-louisa-final\n",
"line 60 Camilo\n",
"line 60 newest patch_floor_rain\n",
"line 60 jacopo.otherness.def\n",
"line 61 2-louisa-final\n",
"line 61 Camilo\n",
"line 61 newest patch_floor_rain\n",
"line 61 jacopo.otherness.def\n",
"line 62 2-louisa-final\n",
"line 62 Camilo\n",
"line 62 newest patch_floor_rain\n",
"line 62 jacopo.otherness.def\n",
"line 63 2-louisa-final\n",
"line 63 Camilo\n",
"line 63 newest patch_floor_rain\n",
"line 63 jacopo.otherness.def\n",
"line 64 2-louisa-final\n",
"line 64 Camilo\n",
"line 64 newest patch_floor_rain\n",
"line 64 jacopo.otherness.def\n",
"line 65 2-louisa-final\n",
"line 65 Camilo\n",
"line 65 newest patch_floor_rain\n",
"line 65 jacopo.otherness.def\n",
"line 66 2-louisa-final\n",
"line 66 Camilo\n",
"line 66 newest patch_floor_rain\n",
"line 66 jacopo.otherness.def\n",
"line 67 2-louisa-final\n",
"line 67 Camilo\n",
"line 67 newest patch_floor_rain\n",
"line 67 jacopo.otherness.def\n",
"line 68 2-louisa-final\n",
"line 68 Camilo\n",
"line 68 newest patch_floor_rain\n",
"line 68 jacopo.otherness.def\n",
"line 69 2-louisa-final\n",
"line 69 Camilo\n",
"line 69 newest patch_floor_rain\n",
"line 69 jacopo.otherness.def\n",
"line 70 2-louisa-final\n",
"line 70 Camilo\n",
"line 70 newest patch_floor_rain\n",
"line 70 jacopo.otherness.def\n",
"line 71 2-louisa-final\n",
"line 71 Camilo\n",
"line 71 newest patch_floor_rain\n",
"line 71 jacopo.otherness.def\n",
"line 72 2-louisa-final\n",
"line 72 Camilo\n",
"line 72 newest patch_floor_rain\n",
"line 72 jacopo.otherness.def\n",
"line 73 2-louisa-final\n",
"line 73 Camilo\n"
]
},
{
"ename": "IndexError",
"evalue": "list index out of range",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-6-c95e08ba452e>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mpatch\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrow\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mf\"line {linenumber} {patch}\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0mline\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mf\"patches/{patch}.txt\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreadlines\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mlinenumber\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0mline\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mline\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrstrip\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"\\n\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mline\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfile\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0moutput\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mend\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m''\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mIndexError\u001b[0m: list index out of range"
]
}
],
"source": [
"output = open(\"my-fantastic-quilt\", 'w')\n",
"for row in quilt:\n",
"\n",
" for linenumber in range(74):\n",
" for patch in row:\n",
" print(f\"line {linenumber} {patch}\")\n",
" line = open(f\"patches/{patch}.txt\").readlines()[linenumber]\n",
" line = line.rstrip(\"\\n\")\n",
" print(line, file=output, end='')\n",
" print(file=output)\n",
"# print(line)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"from reportlab.pdfgen.canvas import Canvas\n",
"from reportlab.lib.pagesizes import A4,A0\n",
"from reportlab.lib.units import mm\n",
"from reportlab.pdfbase.ttfonts import TTFont, pdfmetrics\n",
"\n",
"pagewidth, pageheight = A0\n",
"\n",
"c = Canvas(\"quilts/quilt_WFTF.pdf\", pagesize=(pagewidth, pageheight), bottomup=0) \n",
"\n",
"\n",
"fontpath = \"fonts/mplus-1m-regular.ttf\"\n",
"font = TTFont('1mregular', fontpath)\n",
"pdfmetrics.registerFont(font)\n",
"\n",
"# To set a font in the PDF\n",
"c.setFont('1mregular', 14.4)\n",
"\n",
"start_y = 5*mm\n",
"y = start_y\n",
"lineheight = 4*mm\n",
"\n",
"lines = open(\"my-fantastic-quilt\").readlines()\n",
"\n",
"for line in lines:\n",
" c.drawString(2*mm, y, line)\n",
" y += lineheight\n",
"\n",
"c.save()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}