@classmethod
- def from_xml_file(cls, xml_file, overwrite=False, build_epub=True):
+ def from_xml_file(cls, xml_file, **kwargs):
# use librarian to parse meta-data
book_info = dcparser.parse(xml_file)
xml_file = File(open(xml_file))
try:
- return cls.from_text_and_meta(xml_file, book_info, overwrite, build_epub=build_epub)
+ return cls.from_text_and_meta(xml_file, book_info, **kwargs)
finally:
xml_file.close()
@classmethod
def from_text_and_meta(cls, raw_file, book_info, overwrite=False, build_epub=True, build_txt=True):
+ import re
from tempfile import NamedTemporaryFile
from slughifi import slughifi
from markupstring import MarkupString
# Read book metadata
book_base, book_slug = book_info.url.rsplit('/', 1)
+ if re.search(r'[^a-zA-Z0-9-]', book_slug):
+ raise ValueError('Invalid characters in slug')
book, created = Book.objects.get_or_create(slug=book_slug)
if created: