From f98470d4a05620e09eea6992ccd6deda15ffacbf Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Tue, 26 Jul 2016 17:01:24 -0700 Subject: [PATCH 1/3] Revert "UnspacedList._spaced_position: support the slice at the end fo the list" This reverts commit 85d9ab4d5c2d2afd3c36229a771f77e4536853cf. --- certbot-nginx/certbot_nginx/nginxparser.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/certbot-nginx/certbot_nginx/nginxparser.py b/certbot-nginx/certbot_nginx/nginxparser.py index a4d4a452f..1859777d8 100644 --- a/certbot-nginx/certbot_nginx/nginxparser.py +++ b/certbot-nginx/certbot_nginx/nginxparser.py @@ -279,9 +279,6 @@ class UnspacedList(list): # Normalize indexes like list[-1] etc, and save the result if idx < 0: idx = len(self) + idx - if idx == len(self): - # not an index, but the slice at the end of the list - return len(self.spaced) if not 0 <= idx < len(self): raise IndexError("list index out of range") idx0 = idx From 4eb38fe1670bea6d9e49cd7cb8fd3be46a404be8 Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Tue, 26 Jul 2016 17:09:01 -0700 Subject: [PATCH 2/3] Make spaced list handle an insert past the end of the list --- certbot-nginx/certbot_nginx/nginxparser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/certbot-nginx/certbot_nginx/nginxparser.py b/certbot-nginx/certbot_nginx/nginxparser.py index 1859777d8..edb280d08 100644 --- a/certbot-nginx/certbot_nginx/nginxparser.py +++ b/certbot-nginx/certbot_nginx/nginxparser.py @@ -215,7 +215,8 @@ class UnspacedList(list): def insert(self, i, x): item, spaced_item = self._coerce(x) - self.spaced.insert(self._spaced_position(i), spaced_item) + self.spaced.insert(self._spaced_position(i) if i < len(self) else i, + spaced_item) list.insert(self, i, item) self.dirty = True From 1060ea7c3d21693bfe7cbc3aadc92dbc901febe9 Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Tue, 26 Jul 2016 17:36:58 -0700 Subject: [PATCH 3/3] delint --- certbot-nginx/certbot_nginx/parser.py | 4 ++-- certbot-nginx/certbot_nginx/tests/configurator_test.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/certbot-nginx/certbot_nginx/parser.py b/certbot-nginx/certbot_nginx/parser.py index c0ce6f185..8500179b1 100644 --- a/certbot-nginx/certbot_nginx/parser.py +++ b/certbot-nginx/certbot_nginx/parser.py @@ -532,8 +532,8 @@ def _comment_directive(block, location): if len(block) > location + 1: # there is a block after us next_entry = block[location + 1] else: - # we're at the end of the block, pretend there's a newline after us; it will actually be added later in - # add_directives + # we're at the end of the block, pretend there's a newline after us; it + # will actually be added later in add_directives next_entry = "\n" if isinstance(next_entry, list): if "Certbot" in next_entry[-1]: diff --git a/certbot-nginx/certbot_nginx/tests/configurator_test.py b/certbot-nginx/certbot_nginx/tests/configurator_test.py index d8fc849b7..f77b9d7cd 100644 --- a/certbot-nginx/certbot_nginx/tests/configurator_test.py +++ b/certbot-nginx/certbot_nginx/tests/configurator_test.py @@ -234,7 +234,7 @@ class NginxConfiguratorTest(util.NginxTest): ['index', 'index.html index.htm']]], ['listen', '5001 ssl'], ['ssl_certificate', '/etc/nginx/fullchain.pem'], - ['ssl_certificate_key', '/etc/nginx/key.pem']]+ + ['ssl_certificate_key', '/etc/nginx/key.pem']] + util.filter_comments(self.config.parser.loc["ssl_options"]) ], 2))