mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 08:08:00 +02:00
Merge pull request #6932 from adferrand/pylint-squash
Update Pylint to 1.9.4 (squashed PR)
This commit is contained in:
@@ -91,8 +91,7 @@ class Proxy(object):
|
||||
"""Returns the set of domain names that can be tested against"""
|
||||
if self._test_names:
|
||||
return self._test_names
|
||||
else:
|
||||
return {"example.com"}
|
||||
return {"example.com"}
|
||||
|
||||
def deploy_cert(self, domain, cert_path, key_path, chain_path=None,
|
||||
fullchain_path=None):
|
||||
|
||||
+19
-13
@@ -5,6 +5,8 @@ import subprocess
|
||||
|
||||
import zope.interface
|
||||
|
||||
from acme.magic_typing import Set # pylint: disable=unused-import, no-name-in-module
|
||||
|
||||
from certbot import configuration
|
||||
from certbot_nginx import configurator
|
||||
from certbot_nginx import constants
|
||||
@@ -19,10 +21,6 @@ class Proxy(configurators_common.Proxy):
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
"""A common base for Nginx test configurators"""
|
||||
|
||||
def __init__(self, args):
|
||||
"""Initializes the plugin with the given command line args"""
|
||||
super(Proxy, self).__init__(args)
|
||||
|
||||
def load_config(self):
|
||||
"""Loads the next configuration for the plugin to test"""
|
||||
config = super(Proxy, self).load_config()
|
||||
@@ -48,7 +46,7 @@ class Proxy(configurators_common.Proxy):
|
||||
|
||||
def _prepare_configurator(self):
|
||||
"""Prepares the Nginx plugin for testing"""
|
||||
for k in constants.CLI_DEFAULTS.keys():
|
||||
for k in constants.CLI_DEFAULTS:
|
||||
setattr(self.le_config, "nginx_" + k, constants.os_constant(k))
|
||||
|
||||
conf = configuration.NamespaceConfig(self.le_config)
|
||||
@@ -72,15 +70,23 @@ def _get_server_root(config):
|
||||
|
||||
def _get_names(config):
|
||||
"""Returns all and testable domain names in config"""
|
||||
all_names = set()
|
||||
all_names = set() # type: Set[str]
|
||||
for root, _dirs, files in os.walk(config):
|
||||
for this_file in files:
|
||||
for line in open(os.path.join(root, this_file)):
|
||||
if line.strip().startswith("server_name"):
|
||||
names = line.partition("server_name")[2].rpartition(";")[0]
|
||||
for n in names.split():
|
||||
# Filter out wildcards in both all_names and test_names
|
||||
if not n.startswith("*."):
|
||||
all_names.add(n)
|
||||
update_names = _get_server_names(root, this_file)
|
||||
all_names.update(update_names)
|
||||
non_ip_names = set(n for n in all_names if not util.IP_REGEX.match(n))
|
||||
return all_names, non_ip_names
|
||||
|
||||
|
||||
def _get_server_names(root, filename):
|
||||
"""Returns all names in a config file path"""
|
||||
all_names = set()
|
||||
for line in open(os.path.join(root, filename)):
|
||||
if line.strip().startswith("server_name"):
|
||||
names = line.partition("server_name")[2].rpartition(";")[0]
|
||||
for n in names.split():
|
||||
# Filter out wildcards in both all_names and test_names
|
||||
if not n.startswith("*."):
|
||||
all_names.add(n)
|
||||
return all_names
|
||||
|
||||
@@ -6,8 +6,9 @@ import certbot.interfaces
|
||||
# pylint: disable=no-self-argument,no-method-argument
|
||||
|
||||
|
||||
class IPluginProxy(zope.interface.Interface):
|
||||
class IPluginProxy(zope.interface.Interface): # pylint: disable=inherit-non-class
|
||||
"""Wraps a Certbot plugin"""
|
||||
|
||||
http_port = zope.interface.Attribute(
|
||||
"The port to connect to on localhost for HTTP traffic")
|
||||
|
||||
@@ -17,7 +18,7 @@ class IPluginProxy(zope.interface.Interface):
|
||||
def add_parser_arguments(cls, parser):
|
||||
"""Adds command line arguments needed by the parser"""
|
||||
|
||||
def __init__(args):
|
||||
def __init__(args): # pylint: disable=super-init-not-called
|
||||
"""Initializes the plugin with the given command line args"""
|
||||
|
||||
def cleanup_from_tests(): # type: ignore
|
||||
|
||||
@@ -238,9 +238,8 @@ def test_rollback(plugin, config, backup):
|
||||
if _dirs_are_unequal(config, backup):
|
||||
logger.error("*** Rollback failed for config `%s`", config)
|
||||
return False
|
||||
else:
|
||||
logger.info("Rollback succeeded")
|
||||
return True
|
||||
logger.info("Rollback succeeded")
|
||||
return True
|
||||
|
||||
|
||||
def _create_backup(config, temp_dir):
|
||||
@@ -255,7 +254,7 @@ def _create_backup(config, temp_dir):
|
||||
def _dirs_are_unequal(dir1, dir2):
|
||||
"""Returns True if dir1 and dir2 are unequal"""
|
||||
dircmps = [filecmp.dircmp(dir1, dir2)]
|
||||
while len(dircmps):
|
||||
while dircmps:
|
||||
dircmp = dircmps.pop()
|
||||
if dircmp.left_only or dircmp.right_only:
|
||||
logger.error("The following files and directories are only "
|
||||
|
||||
@@ -35,7 +35,7 @@ def create_le_config(parent_dir):
|
||||
|
||||
config["domains"] = None
|
||||
|
||||
return argparse.Namespace(**config) # pylint: disable=star-args
|
||||
return argparse.Namespace(**config)
|
||||
|
||||
|
||||
def extract_configs(configs, parent_dir):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Tests for certbot_compatibility_test.validator."""
|
||||
import requests
|
||||
import unittest
|
||||
import requests
|
||||
|
||||
import mock
|
||||
import OpenSSL
|
||||
|
||||
Reference in New Issue
Block a user