[library-web/new-website-style] [mallard] don't break on removing the same language several times



commit 0600b0d9015cc42ab23fefc3f65fbd4d2fbebc6b
Author: Frédéric Péters <fpeters 0d be>
Date:   Sun Mar 27 20:14:16 2011 +0530

    [mallard] don't break on removing the same language several times

 src/modtypes/mallard.py |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/modtypes/mallard.py b/src/modtypes/mallard.py
index f0df1d2..1ba348c 100644
--- a/src/modtypes/mallard.py
+++ b/src/modtypes/mallard.py
@@ -232,18 +232,22 @@ class MallardModule(DocModule):
             for doc_page in doc_pages:
                 xml_file = os.path.join(lang_dirname, doc_page)
                 if not os.path.exists(xml_file):
-                    doc.languages.remove(lang)
-                    logging.warn('failed to find %s for lang %s, removing lang' % (xml_file, lang))
+                    if lang in doc.languages:
+                        doc.languages.remove(lang)
+                    logging.warn('failed to find %s for lang %s' % (xml_file, lang))
                     continue
                 try:
                     page = mallard_cache.add_page(xml_file)
                 except xml.parsers.expat.ExpatError:
-                    doc.languages.remove(lang)
-                    logging.warn('failed to add %s to mallarc cache file for lang %s, removing lang' % (
+                    if lang in doc.languages:
+                        doc.languages.remove(lang)
+                    logging.warn('failed to add %s to mallarc cache file for lang %s' % (
                                             xml_file, lang))
                     continue
                 if doc_page == 'index.page':
                     doc.title[lang] = page.link_title.text
+            if not lang in doc.languages:
+                continue
             temporary = tempfile.NamedTemporaryFile()
             mallard_cache.dump(temporary.name)
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]