[kapidox] src: Make kgenframeworksapidox more robust.

Alex Merry alex.merry at kde.org
Wed Nov 11 23:53:31 UTC 2015


Git commit 13a58615d0d49709345cc4dca8eef41b991dd2a2 by Alex Merry.
Committed on 11/11/2015 at 23:51.
Pushed by alexmerry into branch 'master'.

Make kgenframeworksapidox more robust.

It should be harder to break it with unusual or broken metainfo.yaml
files now.

CCMAIL: allen.d.winter at gmail.com
CCMAIL: kde-frameworks-devel at kde.org

M  +1    -1    src/kapidox/data/templates/fwinfo.html
M  +21   -11   src/kgenframeworksapidox

http://commits.kde.org/kapidox/13a58615d0d49709345cc4dca8eef41b991dd2a2

diff --git a/src/kapidox/data/templates/fwinfo.html b/src/kapidox/data/templates/fwinfo.html
index 8e6dfdf..a8f263d 100644
--- a/src/kapidox/data/templates/fwinfo.html
+++ b/src/kapidox/data/templates/fwinfo.html
@@ -37,7 +37,7 @@
       <dd>IRC channel: {{ fwinfo.irc|default("#kde-devel") }} on Freenode</dd>
       <dd><a href="https://mail.kde.org/mailman/listinfo/{{ fwinfo.mailinglist|default("kde-frameworks-devel") }}">Mailing list</a></dd>
 
-{% if fwinfo.libraries|count != 0 %}
+{% if fwinfo.libraries is iterable and fwinfo.libraries|count != 0 %}
     <dt>Use with <a href="https://techbase.kde.org/Development/Tutorials/CMake">CMake</a></dt>
       <dd><pre class="fragment">find_package({{ fwinfo.cmakename }})
 target_link_libraries(yourapp{% for lib in fwinfo.libraries %} {{ lib.cmake }}{% endfor %})</pre></dd>
diff --git a/src/kgenframeworksapidox b/src/kgenframeworksapidox
index 47d0f07..714fc77 100755
--- a/src/kgenframeworksapidox
+++ b/src/kgenframeworksapidox
@@ -102,14 +102,13 @@ def process_toplevel_html_file(outputfile, doxdatadir, tiers, title,
             # Extend framework info
             fw['href'] = fw['outputdir'] + '/html/index.html'
 
-            # Fix broken frameworks lacking platform definitions
-            if fw['platforms'] is None:
-                logging.warning('{} framework lacks platform definitions'.format(fw['fancyname']))
+            try:
+                platform_lst = [x['name'] for x in fw['platforms'] if x['name'] not in (PLATFORM_ALL, PLATFORM_UNKNOWN)]
+                available_platforms.update(set(platform_lst))
+            except (KeyError, TypeError):
+                logging.warning('{} framework lacks valid platform definitions'.format(fw['fancyname']))
                 fw['platforms'] = [dict(name=PLATFORM_UNKNOWN)]
 
-            platform_lst = [x['name'] for x in fw['platforms'] if x['name'] not in (PLATFORM_ALL, PLATFORM_UNKNOWN)]
-            available_platforms.update(set(platform_lst))
-
             lst.append(fw)
 
     lst.sort(key=lambda x: x['fancyname'].lower())
@@ -222,16 +221,27 @@ def create_fw_info(frameworksdir, modulename, maintainers):
     outputdir = modulename
 
     # FIXME: option in yaml file to disable docs
-    metainfo = yaml.load(open(yaml_file))
-    tier = metainfo["tier"]
+    try:
+        metainfo = yaml.load(open(yaml_file))
+    except:
+        logging.warning('Could not load metainfo.yaml for {}, skipping it'.format(modulename))
+        return None
+
+    if metainfo is None:
+        logging.warning('Empty metainfo.yaml for {}, skipping it'.format(modulename))
+        return None
+
+    tier = metainfo.get("tier")
     if tier is None:
-        logging.warning('Could not find tier for {}'.format(framework))
+        logging.warning('Could not find tier for {}, skipping it'.format(modulename))
         return None
     elif tier < 1 or tier > 4:
-        logging.warning('Invalid tier {} for {}'.format(tier, framework))
+        logging.warning('Invalid tier {} for {}, skipping it'.format(tier, modulename))
         return None
 
-    if isinstance(metainfo['maintainer'],list):
+    if 'maintainer' not in metainfo:
+        fw_maintainers = []
+    elif isinstance(metainfo['maintainer'],list):
         fw_maintainers = map(lambda x: maintainers.get(x, None),
                              metainfo['maintainer'])
     else:


More information about the Kde-frameworks-devel mailing list