From c8202dbfb42d49a551c52e1561e373ee5d141b02 Mon Sep 17 00:00:00 2001 From: Erica Portnoy Date: Thu, 12 Oct 2017 17:14:30 -0700 Subject: [PATCH] Address review nits --- certbot-nginx/certbot_nginx/configurator.py | 2 +- certbot-nginx/certbot_nginx/nginxparser.py | 2 +- certbot-nginx/certbot_nginx/parser.py | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/certbot-nginx/certbot_nginx/configurator.py b/certbot-nginx/certbot_nginx/configurator.py index daa1494a6..ba6c565c0 100644 --- a/certbot-nginx/certbot_nginx/configurator.py +++ b/certbot-nginx/certbot_nginx/configurator.py @@ -266,7 +266,7 @@ class NginxConfigurator(common.Installer): self.new_vhost.names = set() self.new_vhost.names.add(domain) - name_block = [['\n ', 'server_name', ' ', " ".join(self.new_vhost.names)]] + name_block = [['\n ', 'server_name', ' ', ' '.join(self.new_vhost.names)]] self.parser.add_server_directives(self.new_vhost, name_block, replace=True) return self.new_vhost diff --git a/certbot-nginx/certbot_nginx/nginxparser.py b/certbot-nginx/certbot_nginx/nginxparser.py index 1db6e41f5..14481e298 100644 --- a/certbot-nginx/certbot_nginx/nginxparser.py +++ b/certbot-nginx/certbot_nginx/nginxparser.py @@ -2,12 +2,12 @@ # Forked from https://github.com/fatiherikli/nginxparser (MIT Licensed) import copy import logging -import six from pyparsing import ( Literal, White, Forward, Group, Optional, OneOrMore, QuotedString, Regex, ZeroOrMore, Combine) from pyparsing import stringEnd from pyparsing import restOfLine +import six logger = logging.getLogger(__name__) diff --git a/certbot-nginx/certbot_nginx/parser.py b/certbot-nginx/certbot_nginx/parser.py index f4aa15208..3eb6264aa 100644 --- a/certbot-nginx/certbot_nginx/parser.py +++ b/certbot-nginx/certbot_nginx/parser.py @@ -5,6 +5,7 @@ import logging import os import pyparsing import re + import six from certbot import errors @@ -322,7 +323,7 @@ class NginxParser(object): :returns: A vhost object for the newly created vhost :rtype: :class:`~certbot_nginx.obj.VirtualHost` """ - # TODO: do the right thing for debian + # TODO: https://github.com/certbot/certbot/issues/5185 # put it in the same file as the template, at the same level enclosing_block = self.parsed[vhost_template.filep] for index in vhost_template.path[:-1]: @@ -588,7 +589,7 @@ def _add_directive(block, directive, replace): directive_name = directive[0] def can_append(loc, dir_name): """ Can we append this directive to the block? """ - return loc is None or (isinstance(dir_name, six.string_types)\ + return loc is None or (isinstance(dir_name, six.string_types) and dir_name in REPEATABLE_DIRECTIVES) err_fmt = 'tried to insert directive "{0}" but found conflicting "{1}".'