- 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)
+ source = parsed_dc.source_name
+ if source:
+ source = "\n\nTekst opracowany na podstawie: " + source
+ else:
+ source = ''
+
+ 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ę ufundowali i ufundowały: %s." % funders
+ else:
+ description = 'Publikacja zrealizowana w ramach projektu Wolne Lektury (http://wolnelektury.pl).'
+ url = '*' * 10
+ license = ""
+ license_description = ""
+ source = ""
+ contributors = ""
+ funders = ""
+ return OutputFile.from_string((TEMPLATE % {
+ 'description': description,
+ 'url': url,
+ 'license_description': license_description,
+ 'text': unicode(result),
+ 'source': source,
+ 'contributors': contributors,
+ 'funders': funders,
+ }).encode('utf-8'))