from mako.template import Template

class Line(object):
    template = Template("""${label}. \\
% for word in words:
${word} \\
% endfor 
% if lemmas:
\n#lem: \\
% for lemma in lemmas:
${lemma}; \\
% endfor \n
%endif
""", output_encoding='utf-8')


    def __init__(self, label):
        self.label = label
        self.words = []
        self.lemmas = []
        self.witnesses = []
        self.translation = None
        self.notes = []
        self.references = []
        self.links = []
        
    def __str__(self):
        return self.template.render_unicode(**vars(self))
    
    def serialize(self):
        return self.template.render_unicode(**vars(self))

from mako.template import Template

class Line(object):
    template = Template("""\n${label}.\t\\
${' '.join(words)}\\
% if references:
% for reference in references:
^${reference}^ 
% endfor
% endif
% if lemmas:
\n#lem:\\
${'; '.join(lemmas)}\\
% endif
% if notes:
\n
% for note in notes:
${note.serialize()}
% endfor
% endif
% if links:
\n#link: \\
% for link in links:
${link}; 
% endfor
% endif
""", output_encoding='utf-8')


    def __init__(self, label):
        self.label = label
        self.words = []
        self.lemmas = []
        self.witnesses = []
        self.translation = None
        self.notes = []
        self.references = []
        self.links = []
        
    def __str__(self):
        return self.template.render_unicode(**vars(self))
    
    def serialize(self):
        return self.template.render_unicode(**vars(self))

Use join for serializing words and lemmas to avoid printing last ; as required by ATF format. Print also references, notes and links.
Use join for serializing words and lemmas to avoid printing last ; as required by ATF format. Print also references, notes and links.
