-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNameTags.py
101 lines (92 loc) · 2.07 KB
/
NameTags.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
from pathlib import Path
import csv
import pprint
import os
import sys
label_width = 335
label_height = 230
raw = [line for line in
next(Path().glob("*-WTF.csv")).read_text().splitlines()
if "Timestamp" not in line]
records = { f"{row[7]}" for row in csv.reader(raw) }
pprint.pprint(records)
with open("Attendees.txt", 'w') as attendees:
for n, rec in enumerate(sorted(records)):
first, last = rec.split(' ')
print(first, last)
attendees.write(f"{n + 1} {first} {last}\n")
#sys.exit()
name_tags_table_begin = f"""
<style>
.nameTags {{
border-collapse:collapse;
padding:5px;
}}
.nameTags td {{
padding:5px;
}}
.oneTag {{
border-spacing:0;
margin-bottom:5px;
}}
.oneTag td {{
width:{label_width}px;
height:{label_height}px;
border-bottom:1px solid #000000;
}}
h1, h3 {{
font-family: Sans-Serif;
line-height: 100%;
padding-left: 10px;
padding-top: 0;
margin: 0;
text-align: left;
}}
h1 {{
font-size: 4.5em;
margin-bottom: 5px;
}}
h3 {{
}}
img {{
vertical-align: top;
height: 70px;
width: 100%;
}}
.pageBreak {{
page-break-before: always;
}}
</style>
<table class="nameTags">
<tbody>
"""
def name_tag_row(first, last):
return f"""
<table class="oneTag">
<tbody>
<tr>
<td>
<img src="WinterTechForumBanner.png">
<h1>{first}</h1><h3>{last}</h3></td>
<td>
<img src="WinterTechForumBanner.png">
<h1>{first}</h1><h3>{last}</h3></td>
</tr>
<tbody>
</table>
"""
name_tags_table_end = """
<tbody>
</table>
"""
with open("NameTags.html", 'w') as name_tags:
name_tags.write(f"{name_tags_table_begin}")
for n, rec in enumerate(sorted(records)):
first, last = rec.split(' ')
full_name = f"{first} {last}"
name_tags.write(f"{name_tag_row(first, last)}")
if (n+1) % 4 == 0:
name_tags.write('<div class = "pageBreak">\n')
name_tags.write(f"{name_tags_table_end}")
os.system("subl NameTags.html")
os.system("call start NameTags.html")