- line_length = 0
- lines = [[]]
- for word in words:
- line_length += len(word) + 1
- if line_length > wrapping:
- # Max line length was exceeded. We create new line
- lines.append([])
- line_length = len(word)
- lines[-1].append(word)
- return '\n'.join(' '.join(line) for line in lines)
-
-
-# Register substitute_entities function with lxml
-ns = etree.FunctionNamespace('http://wolnelektury.pl/functions')
-ns['strip'] = strip
-ns['substitute_entities'] = substitute_entities
-ns['wrap_words'] = wrap_words
-
-
-def transform(input_filename, output_filename, **options):
- """Transforms file input_filename in XML to output_filename in TXT."""
- # Parse XSLT
- style_filename = os.path.join(os.path.dirname(__file__), 'book2txt.xslt')
- style = etree.parse(style_filename)
-
- if is_file:
- document = WLDocument.from_file(input, True)
+ contributors = ', '.join(person.readable() for person in
+ sorted(set(p for p in (parsed_dc.technical_editors + parsed_dc.editors) if p)))
+ if contributors:
+ contributors = "\n\nOpracowanie redakcyjne i przypisy: %s." % contributors
+ funders = ', '.join(parsed_dc.funders)
+ if funders:
+ funders = u"\n\nPublikację wsparli i wsparły: %s." % funders
+ publisher = '\n\nWydawca: ' + ', '.join(parsed_dc.publisher)
+ isbn = getattr(parsed_dc, 'isbn_txt', None)
+ if isbn:
+ isbn = '\n\n' + isbn
+ else:
+ isbn = ''
+ else:
+ description = 'Publikacja zrealizowana w ramach projektu Wolne Lektury (http://wolnelektury.pl).'
+ url = '*' * 10
+ license_description = ""
+ source = ""
+ contributors = ""
+ funders = ""
+ publisher = ""
+ isbn = ""
+ result = (TEMPLATE % {
+ 'description': description,
+ 'url': url,
+ 'license_description': license_description,
+ 'text': unicode(result),
+ 'source': source,
+ 'contributors': contributors,
+ 'funders': funders,
+ 'publisher': publisher,
+ 'isbn': isbn,
+ }).encode('utf-8')