gamnit: fix doc of `ModelAsset` to represent the current API
[nit.git] / contrib / rss_downloader / src / rss_downloader.nit
index 83e47c2..022543e 100644 (file)
@@ -170,7 +170,7 @@ class Downloader
                        # Download element
                        if sys.verbose then print "+ Acting on {element}"
 
-                       tool_config.act_on element
+                       tool_config.as(not null).act_on element
 
                        # Add `unique_id` to log
                        history.add unique_id
@@ -205,7 +205,7 @@ class Downloader
                                continue
                        end
 
-                       for dir in source_folder.files do if dir.stat.is_dir then
+                       for dir in source_folder.files do if dir.stat.as(not null).is_dir then
                                folder_names.add dir.filename
                        end
                end
@@ -271,8 +271,18 @@ redef class Text
 
                var elements = new Array[Element]
                for item in items do
-                       var title = item[tool_config.tag_title].first.as(XMLStartTag).data
-                       var link = item[tool_config.tag_link].first.as(XMLStartTag).data
+                       var title = item[tool_config.as(not null).tag_title].first.as(XMLStartTag).data
+                       var link = item[tool_config.as(not null).tag_link].first.as(XMLStartTag).data
+
+                       if title == null then
+                               print_error "RSS Parse Error: title is null"
+                               return elements
+                       end
+
+                       if link == null then
+                               print_error "RSS Parse Error: link is null"
+                               return elements
+                       end
 
                        elements.add new Element(title, link)
                end
@@ -289,12 +299,8 @@ redef class Text
        fun gunzip: String
        do
                var proc = new ProcessDuplex("gunzip", new Array[String]...)
-               proc.write self
-               proc.stream_out.close
-               var res = proc.read_all
-               proc.stream_in.close
-               proc.wait
-               assert proc.status == 0
+               var res = proc.write_and_read(self)
+               assert proc.status == 0 else print_error "gunzip failed: {proc.last_error or else "Unknown"}"
                return res
        end
 end