From: Library Admin Date: Wed, 5 Jun 2013 09:53:50 +0000 (+0200) Subject: obvious crash avoidance fixes X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/ea995d6aea1cc1b19502825fec5f5d0445d632c4?ds=inline obvious crash avoidance fixes --- diff --git a/librarian/cover.py b/librarian/cover.py index b53de30..1db96cb 100644 --- a/librarian/cover.py +++ b/librarian/cover.py @@ -121,7 +121,10 @@ class Cover(object): } def __init__(self, book_info, format=None): - self.author = ", ".join(auth.readable() for auth in book_info.authors) + try: + self.author = ", ".join(auth.readable() for auth in book_info.authors) + except AttributeError: + self.author = "" self.title = book_info.title if format is not None: self.format = format diff --git a/librarian/pyhtml.py b/librarian/pyhtml.py index 0f23125..775def1 100644 --- a/librarian/pyhtml.py +++ b/librarian/pyhtml.py @@ -82,7 +82,7 @@ class EduModule(Xmill): } submill = EduModule(dict(self.options.items() + {'sub_gen': True}.items())) - opis = submill.generate(element.xpath('opis')[0]) + opis = submill.generate(element.xpath('opis')[0]) if len(element.xpath('opis')) else "" n = element.xpath('wskazowki') if n: wskazowki = submill.generate(n[0]) @@ -196,7 +196,7 @@ u"""%(wskazowki)s subgen = EduModule(self.options) definiens_s = subgen.generate(definiens) else: - print '!! Missing definiendum in source:', element.text + pass # print '!! Missing definiendum in source:', element.text return u"
", u"
" + definiens_s @@ -334,7 +334,7 @@ class Wybor(Exercise): if not pytania: pytania = [element] for p in pytania: - solutions = re.split(r"[, ]+", p.attrib['rozw']) + solutions = re.split(r"[, ]+", p.attrib.get('rozw', '')) if len(solutions) != 1: is_single_choice = False break @@ -471,14 +471,14 @@ class Przyporzadkuj(Exercise): if self.options['handles']: return '
  • %s' % (element.attrib['rozw'], self.piece_counter, self.piece_counter), '
  • ' else: - return '
  • ' % (element.attrib['rozw'], self.piece_counter), '
  • ' + return '
  • ' % (element.attrib.get('rozw', ''), self.piece_counter), '
  • ' elif self.options['predicate']: if self.options['min']: placeholders = u'
  • ' * self.options['min'] else: placeholders = u'
  • ' - return '
  • ' % element.attrib, '
  • ' + return '
  • ' % element.attrib.get('nazwa', ''), '
  • ' else: return super(Przyporzadkuj, self).handle_punkt(element) @@ -528,7 +528,7 @@ class EduModuleFormat(Format): order = dict(reversed(k) for k in enumerate(self.PRIMARY_MATERIAL_FORMATS)) mats = self.materials_by_slug.get(slug, {}).items() if not mats: - print "!! Material missing: '%s'" % slug + pass # print "!! Material missing: '%s'" % slug return sorted(mats, key=lambda (x, y): order.get(x, x)) def url_for_material(self, slug, fmt):