コード例 #1
0
ファイル: example.py プロジェクト: alexbepple/csv2buttons
from ibp.buttonsheet import ButtonSheet
from ibp.templates import TemplateFor55Buttons
from ibp.elements import FlowableFactory
import xing

from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont

import codecs
from subprocess import call


pdfmetrics.registerFont(TTFont('default', 'GillSansBold.ttf'))

pdf_filename = "xing.pdf"
template = TemplateFor55Buttons(pdf_filename)

with codecs.open('xing.csv', encoding='utf-16-le') as f:
    lines = f.readlines()
lines = [line.encode('utf-8') for line in lines]

names = xing.extract_names_from_csv(lines)
ButtonSheet().add_buttons(names).build(template, FlowableFactory())

call(["xdg-open", pdf_filename])

コード例 #2
0
 def cleans_up_names(self):
     names = xing.extract_names_from_csv(['"Joanna"'])
     assert_equal(["Joanna"], names)
コード例 #3
0
 def ignores_all_columns_but_first__columns_are_tab_separated(self):
     names = xing.extract_names_from_csv(['"Joanna"	"was"	"born"'])
     assert_equal(["Joanna"], names)
コード例 #4
0
 def ignores_header_which_is_discernible_by_lack_of_quotation(self):
     names = xing.extract_names_from_csv(['name', '"Joanna"'])
     assert_equal(["Joanna"], names)
コード例 #5
0
 def ignores_empty_lines(self):
     names = xing.extract_names_from_csv([''])
     assert_equal([], names)