diff --git a/src/cffconvert/lib/cff_1_0_x/apalike.py b/src/cffconvert/lib/cff_1_0_x/apalike.py index a94f499d..c7f93f60 100644 --- a/src/cffconvert/lib/cff_1_0_x/apalike.py +++ b/src/cffconvert/lib/cff_1_0_x/apalike.py @@ -16,12 +16,14 @@ def add_author(self): authors_apalike = [ApalikeAuthor(a).as_string() for a in authors_cff] authors_apalike_filtered = [a for a in authors_apalike if a is not None] n_authors = len(authors_apalike_filtered) - if n_authors > 2: - self.author = ", ".join(authors_apalike_filtered[:-1]) + ", and " + authors_apalike_filtered[-1] - if n_authors == 2: - self.author = ", ".join(authors_apalike_filtered[:-1]) + " and " + authors_apalike_filtered[-1] - if n_authors == 1: + if n_authors < 1: + pass + elif n_authors == 1: self.author = ", ".join(authors_apalike_filtered) + elif n_authors == 2: + self.author = ", ".join(authors_apalike_filtered[:-1]) + " and " + authors_apalike_filtered[-1] + else: + self.author = ", ".join(authors_apalike_filtered[:-1]) + ", and " + authors_apalike_filtered[-1] return self def add_year(self): diff --git a/src/cffconvert/lib/cff_1_1_x/apalike.py b/src/cffconvert/lib/cff_1_1_x/apalike.py index cae1f3ba..7a6cf3a0 100644 --- a/src/cffconvert/lib/cff_1_1_x/apalike.py +++ b/src/cffconvert/lib/cff_1_1_x/apalike.py @@ -14,12 +14,14 @@ def add_author(self): authors_apalike = [ApalikeAuthor(a).as_string() for a in authors_cff] authors_apalike_filtered = [a for a in authors_apalike if a is not None] n_authors = len(authors_apalike_filtered) - if n_authors > 2: - self.author = ", ".join(authors_apalike_filtered[:-1]) + ", and " + authors_apalike_filtered[-1] - if n_authors == 2: - self.author = ", ".join(authors_apalike_filtered[:-1]) + " and " + authors_apalike_filtered[-1] - if n_authors == 1: + if n_authors < 1: + pass + elif n_authors == 1: self.author = ", ".join(authors_apalike_filtered) + elif n_authors == 2: + self.author = ", ".join(authors_apalike_filtered[:-1]) + " and " + authors_apalike_filtered[-1] + else: + self.author = ", ".join(authors_apalike_filtered[:-1]) + ", and " + authors_apalike_filtered[-1] return self def add_year(self): diff --git a/src/cffconvert/lib/cff_1_2_x/apalike.py b/src/cffconvert/lib/cff_1_2_x/apalike.py index 3965ec1b..8951119b 100644 --- a/src/cffconvert/lib/cff_1_2_x/apalike.py +++ b/src/cffconvert/lib/cff_1_2_x/apalike.py @@ -14,12 +14,14 @@ def add_author(self): authors_apalike = [ApalikeAuthor(a).as_string() for a in authors_cff] authors_apalike_filtered = [a for a in authors_apalike if a is not None] n_authors = len(authors_apalike_filtered) - if n_authors > 2: - self.author = ", ".join(authors_apalike_filtered[:-1]) + ", and " + authors_apalike_filtered[-1] - if n_authors == 2: - self.author = ", ".join(authors_apalike_filtered[:-1]) + " and " + authors_apalike_filtered[-1] - if n_authors == 1: + if n_authors < 1: + pass + elif n_authors == 1: self.author = ", ".join(authors_apalike_filtered) + elif n_authors == 2: + self.author = ", ".join(authors_apalike_filtered[:-1]) + " and " + authors_apalike_filtered[-1] + else: + self.author = ", ".join(authors_apalike_filtered[:-1]) + ", and " + authors_apalike_filtered[-1] return self def add_year(self): diff --git a/src/cffconvert/lib/cff_1_3_x/apalike.py b/src/cffconvert/lib/cff_1_3_x/apalike.py index ce99135e..83514558 100644 --- a/src/cffconvert/lib/cff_1_3_x/apalike.py +++ b/src/cffconvert/lib/cff_1_3_x/apalike.py @@ -14,12 +14,14 @@ def add_author(self): authors_apalike = [ApalikeAuthor(a).as_string() for a in authors_cff] authors_apalike_filtered = [a for a in authors_apalike if a is not None] n_authors = len(authors_apalike_filtered) - if n_authors > 2: - self.author = ", ".join(authors_apalike_filtered[:-1]) + ", and " + authors_apalike_filtered[-1] - if n_authors == 2: - self.author = ", ".join(authors_apalike_filtered[:-1]) + " and " + authors_apalike_filtered[-1] - if n_authors == 1: + if n_authors < 1: + pass + elif n_authors == 1: self.author = ", ".join(authors_apalike_filtered) + elif n_authors == 2: + self.author = ", ".join(authors_apalike_filtered[:-1]) + " and " + authors_apalike_filtered[-1] + else: + self.author = ", ".join(authors_apalike_filtered[:-1]) + ", and " + authors_apalike_filtered[-1] return self def add_year(self):