Repository: biolab/orange3-text

Issue:
Import Documents: handle no skipped documents
**Describe the bug**
We forgot to handle the case where all the documents are read correctly and there are no skipped documents on the output.

**To Reproduce**
Steps to reproduce the behavior:
Load good files with Import Documents.

**Expected behavior**
No error.

**Orange version:**
3.27.dev

**Text add-on version:**
1.2.0

**Additional context**
```
Traceback (most recent call last):
  File "/Users/ajda/orange/orange3-text/orangecontrib/text/widgets/owimportdocuments.py", line 556, in __onRunFinished
    self.commit()
  File "/Users/ajda/orange/orange3-text/orangecontrib/text/widgets/owimportdocuments.py", line 590, in commit
    skipped_table.name = "Skipped documents"
AttributeError: 'NoneType' object has no attribute 'name'
```



Discussion:

Resolving patch:
diff --git a/orangecontrib/text/widgets/owimportdocuments.py b/orangecontrib/text/widgets/owimportdocuments.py
--- a/orangecontrib/text/widgets/owimportdocuments.py
+++ b/orangecontrib/text/widgets/owimportdocuments.py
@@ -579,15 +579,17 @@ def commit(self):
         Create and commit a Corpus from the collected text meta data.
         """
         self.Outputs.data.send(self.corpus)
-        skipped_table = (
-            Table.from_list(
-                SKIPPED_DOMAIN,
-                [[x, os.path.join(self.currentPath, x)]
-                 for x in self.skipped_documents]
+        if self.skipped_documents:
+            skipped_table = (
+                Table.from_list(
+                    SKIPPED_DOMAIN,
+                    [[x, os.path.join(self.currentPath, x)]
+                     for x in self.skipped_documents]
+                )
             )
-            if self.skipped_documents else None
-        )
-        skipped_table.name = "Skipped documents"
+            skipped_table.name = "Skipped documents"
+        else:
+            skipped_table = None
         self.Outputs.skipped_documents.send(skipped_table)
 
     def onDeleteWidget(self):


Test patch:
diff --git a/orangecontrib/text/widgets/tests/data/sample_pdf_corrupted.pdf b/orangecontrib/text/widgets/tests/data/corrupted/sample_pdf_corrupted.pdf
similarity index 100%
rename from orangecontrib/text/widgets/tests/data/sample_pdf_corrupted.pdf
rename to orangecontrib/text/widgets/tests/data/corrupted/sample_pdf_corrupted.pdf
diff --git a/orangecontrib/text/widgets/tests/data/sample_docx.docx b/orangecontrib/text/widgets/tests/data/good/sample_docx.docx
similarity index 100%
rename from orangecontrib/text/widgets/tests/data/sample_docx.docx
rename to orangecontrib/text/widgets/tests/data/good/sample_docx.docx
diff --git a/orangecontrib/text/widgets/tests/data/sample_odt.odt b/orangecontrib/text/widgets/tests/data/good/sample_odt.odt
similarity index 100%
rename from orangecontrib/text/widgets/tests/data/sample_odt.odt
rename to orangecontrib/text/widgets/tests/data/good/sample_odt.odt
diff --git a/orangecontrib/text/widgets/tests/data/sample_pdf.pdf b/orangecontrib/text/widgets/tests/data/good/sample_pdf.pdf
similarity index 100%
rename from orangecontrib/text/widgets/tests/data/sample_pdf.pdf
rename to orangecontrib/text/widgets/tests/data/good/sample_pdf.pdf
diff --git a/orangecontrib/text/widgets/tests/data/sample_txt.txt b/orangecontrib/text/widgets/tests/data/good/sample_txt.txt
similarity index 100%
rename from orangecontrib/text/widgets/tests/data/sample_txt.txt
rename to orangecontrib/text/widgets/tests/data/good/sample_txt.txt
diff --git a/orangecontrib/text/widgets/tests/test_owimportdocuments.py b/orangecontrib/text/widgets/tests/test_owimportdocuments.py
--- a/orangecontrib/text/widgets/tests/test_owimportdocuments.py
+++ b/orangecontrib/text/widgets/tests/test_owimportdocuments.py
@@ -17,6 +17,13 @@ def test_current_path(self):
         path = os.path.join(os.path.dirname(__file__), "data")
         self.assertEqual(path, self.widget.currentPath)
 
+    def test_no_skipped(self):
+        path = os.path.join(os.path.dirname(__file__), "data", "good")
+        self.widget.setCurrentPath(path)
+        self.widget.reload()
+        self.wait_until_finished()
+        self.assertIsNone(self.get_output(self.widget.Outputs.skipped_documents))
+
     def test_output(self):
         output = self.get_output(self.widget.Outputs.data)
         self.assertEqual(4, len(output))