From c0633ec3acec18c171d089a0677efdf980ca0290 Mon Sep 17 00:00:00 2001 From: sydneyli Date: Fri, 6 Dec 2019 17:38:35 -0800 Subject: [PATCH] Implement ApacheBlockNode.delete_child --- .../certbot_apache/_internal/apacheparser.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/certbot-apache/certbot_apache/_internal/apacheparser.py b/certbot-apache/certbot_apache/_internal/apacheparser.py index ce9c49488..50258c9d6 100644 --- a/certbot-apache/certbot_apache/_internal/apacheparser.py +++ b/certbot-apache/certbot_apache/_internal/apacheparser.py @@ -206,9 +206,21 @@ class ApacheBlockNode(ApacheDirectiveNode): filepath=assertions.PASS, metadata=self.metadata)] - def delete_child(self, child): # pragma: no cover + def delete_child(self, child): """Deletes a ParserNode from the sequence of children""" - return + index = -1 + i = None + for i, elem in enumerate(self.children): + if elem == child: + index = i + break + if index < 0: + raise errors.PluginError("Could not find child node to delete") + children_list = list(self.children) + thing = children_list.pop(i) + self.children = tuple(children_list) + self._raw_children.remove(i) + return thing def unsaved_files(self): # pragma: no cover """Returns a list of unsaved filepaths"""