Repository: regro/regolith

Issue:
use get for all dict access in builders
see https://travis-ci.org/Billingegroup/rg-db-public/jobs/343122765#L1681

Discussion:

Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index a5d66376..ce3426be 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -4,17 +4,6 @@ Regolith Change Log
 
 .. current developments
 
-v0.1.9
-====================
-
-**Fixed:**
-
-* ``all_documents`` now returns the values of an empty dict if the collection
-  doesn't exist
-
-
-
-
 v0.1.8
 ====================
 
diff --git a/news/fix_abstract_error.rst b/news/fix_abstract_error.rst
new file mode 100644
index 00000000..a9120cdb
--- /dev/null
+++ b/news/fix_abstract_error.rst
@@ -0,0 +1,14 @@
+**Added:** None
+
+**Changed:** None
+
+**Deprecated:** None
+
+**Removed:** None
+
+**Fixed:**
+
+* ``all_documents`` now returns the values of an empty dict if the collection
+  doesn't exist
+
+**Security:** None
diff --git a/news/fix_get_author.rst b/news/fix_get_author.rst
new file mode 100644
index 00000000..2114a39b
--- /dev/null
+++ b/news/fix_get_author.rst
@@ -0,0 +1,13 @@
+**Added:** None
+
+**Changed:** None
+
+**Deprecated:** None
+
+**Removed:** None
+
+**Fixed:**
+
+* Use get syntax with ``filter_publications`` in case author not in dict
+
+**Security:** None
diff --git a/regolith/__init__.py b/regolith/__init__.py
index 1c98a23a..c3bb2961 100644
--- a/regolith/__init__.py
+++ b/regolith/__init__.py
@@ -1,1 +1,1 @@
-__version__ = '0.1.9'
+__version__ = '0.1.8'
diff --git a/regolith/tools.py b/regolith/tools.py
index 46e1e680..076b25df 100644
--- a/regolith/tools.py
+++ b/regolith/tools.py
@@ -100,7 +100,7 @@ def month_and_year(m=None, y=None):
 
 
 def filter_publications(citations, authors, reverse=False, bold=True):
-    """Filter publications by the author(s)
+    """Filter publications by the author(s)/editor(s)
 
     Parameters
     ----------
@@ -115,7 +115,9 @@ def filter_publications(citations, authors, reverse=False, bold=True):
     """
     pubs = []
     for pub in citations:
-        if len(set(pub['author']) & authors) == 0:
+        if len(set(pub.get('author', []))
+               & set(pub.get('editor', []))
+               & authors) == 0:
             continue
         pub = deepcopy(pub)
         if bold:
diff --git a/setup.py b/setup.py
index 3cdd619e..b6f62850 100755
--- a/setup.py
+++ b/setup.py
@@ -28,7 +28,7 @@ def main():
         description='A research group content management system',
         long_description=readme,
         license='CC0',
-        version='0.1.9',
+        version='0.1.8',
         author='Anthony Scopatz',
         maintainer='Anthony Scopatz',
         author_email='scopatz@gmail.com',


Test patch:
diff --git a/tests/test_tools.py b/tests/test_tools.py
new file mode 100644
index 00000000..0b4e9060
--- /dev/null
+++ b/tests/test_tools.py
@@ -0,0 +1,6 @@
+from regolith.tools import filter_publications
+
+
+def test_author_publications():
+    citations = [{'author': ['CJ', 'SJLB']}, {'editor': 'SJLB'}]
+    filter_publications(citations, {'SJLB'})