From 3734710f1c90f8202d7067169921eb4e33d453c8 Mon Sep 17 00:00:00 2001 From: Jakub Warmuz Date: Sun, 25 Jan 2015 10:23:21 +0000 Subject: [PATCH] Fix locally disable pylint messages --- letsencrypt/client/apache/configurator.py | 7 ++--- letsencrypt/client/apache/obj.py | 6 ++--- letsencrypt/client/augeas_configurator.py | 9 +++---- letsencrypt/client/client.py | 2 +- letsencrypt/client/client_authenticator.py | 3 +-- letsencrypt/client/display.py | 27 ++++++++++++------- letsencrypt/client/revoker.py | 3 +-- .../client/tests/apache/parser_test.py | 3 +-- letsencrypt/client/tests/auth_handler_test.py | 13 +++++---- .../client/tests/challenge_util_test.py | 3 ++- 10 files changed, 39 insertions(+), 37 deletions(-) diff --git a/letsencrypt/client/apache/configurator.py b/letsencrypt/client/apache/configurator.py index 9f5e6929f..176e33633 100644 --- a/letsencrypt/client/apache/configurator.py +++ b/letsencrypt/client/apache/configurator.py @@ -342,9 +342,8 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): return vhs - # pylint: disable=anomalous-backslash-in-string def is_name_vhost(self, target_addr): - """Returns if vhost is a name based vhost + r"""Returns if vhost is a name based vhost NameVirtualHost was deprecated in Apache 2.4 as all VirtualHosts are now NameVirtualHosts. If version is earlier than 2.4, check if addr @@ -962,10 +961,8 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): ########################################################################### # Challenges Section ########################################################################### - # pylint: disable=no-self-use, unused-argument - def get_chall_pref(self, domain): + def get_chall_pref(self, unused_domain): # pylint: disable=no-self-use """Return list of challenge preferences.""" - return ["dvsni"] def perform(self, chall_list): diff --git a/letsencrypt/client/apache/obj.py b/letsencrypt/client/apache/obj.py index 647724a48..905e3f192 100644 --- a/letsencrypt/client/apache/obj.py +++ b/letsencrypt/client/apache/obj.py @@ -43,8 +43,7 @@ class Addr(object): return self.__class__((self.tup[0], port)) -# pylint: disable=too-few-public-methods -class VirtualHost(object): +class VirtualHost(object): # pylint: disable=too-few-public-methods """Represents an Apache Virtualhost. :ivar str filep: file path of VH @@ -58,7 +57,8 @@ class VirtualHost(object): """ - def __init__(self, filep, path, addrs, ssl, enabled, names=None): # pylint: disable=too-many-arguments + def __init__(self, filep, path, addrs, ssl, enabled, names=None): + # pylint: disable=too-many-arguments """Initialize a VH.""" self.filep = filep self.path = path diff --git a/letsencrypt/client/augeas_configurator.py b/letsencrypt/client/augeas_configurator.py index 793b141d6..d6e6260c1 100644 --- a/letsencrypt/client/augeas_configurator.py +++ b/letsencrypt/client/augeas_configurator.py @@ -324,9 +324,9 @@ class AugeasConfigurator(object): return True, "" - # pylint: disable=no-self-use, anomalous-backslash-in-string def register_file_creation(self, temporary, *files): - """Register the creation of all files during letsencrypt execution. + # pylint: disable=no-self-use + r"""Register the creation of all files during letsencrypt execution. Call this method before writing to the file to make sure that the file will be cleaned up if the program exits unexpectedly. @@ -375,8 +375,7 @@ class AugeasConfigurator(object): # Need to reload configuration after these changes take effect self.aug.load() - # pylint: disable=no-self-use - def _remove_contained_files(self, file_list): + def _remove_contained_files(self, file_list): # pylint: disable=no-self-use """Erase all files contained within file_list. :param str file_list: file containing list of file paths to be deleted @@ -408,8 +407,8 @@ class AugeasConfigurator(object): return True - # pylint: disable=no-self-use def _finalize_checkpoint(self, cp_dir, title): + # pylint: disable=no-self-use """Move IN_PROGRESS checkpoint to timestamped checkpoint. Adds title to cp_dir CHANGES_SINCE diff --git a/letsencrypt/client/client.py b/letsencrypt/client/client.py index 0e4fa47f0..77416234b 100644 --- a/letsencrypt/client/client.py +++ b/letsencrypt/client/client.py @@ -132,8 +132,8 @@ class Client(object): return self.network.send_and_receive_expected( acme.certificate_request(csr_der, self.authkey.pem), "certificate") - # pylint: disable=no-self-use def save_certificate(self, certificate_dict, cert_path, chain_path): + # pylint: disable=no-self-use """Saves the certificate received from the ACME server. :param dict certificate_dict: certificate message from server diff --git a/letsencrypt/client/client_authenticator.py b/letsencrypt/client/client_authenticator.py index 1847d3760..699e5e598 100644 --- a/letsencrypt/client/client_authenticator.py +++ b/letsencrypt/client/client_authenticator.py @@ -25,8 +25,7 @@ class ClientAuthenticator(object): """ self.rec_token = recovery_token.RecoveryToken(server) - # pylint: disable=unused-argument,no-self-use - def get_chall_pref(self, domain): + def get_chall_pref(self, unused_domain): # pylint: disable=no-self-use """Return list of challenge preferences.""" return ["recoveryToken"] diff --git a/letsencrypt/client/display.py b/letsencrypt/client/display.py index 05730bfc4..867675495 100644 --- a/letsencrypt/client/display.py +++ b/letsencrypt/client/display.py @@ -41,10 +41,12 @@ class NcursesDisplay(CommonDisplayMixin): self.width = width self.height = height - def generic_notification(self, message): # pylint: disable=missing-docstring + def generic_notification(self, message): + # pylint: disable=missing-docstring self.dialog.msgbox(message, width=self.width) - def generic_menu(self, message, choices, unused_input_text=""): # pylint: disable=missing-docstring + def generic_menu(self, message, choices, unused_input_text=""): + # pylint: disable=missing-docstring # Can accept either tuples or just the actual choices if choices and isinstance(choices[0], tuple): code, selection = self.dialog.menu( @@ -60,7 +62,8 @@ class NcursesDisplay(CommonDisplayMixin): def generic_input(self, message): # pylint: disable=missing-docstring return self.dialog.inputbox(message) - def generic_yesno(self, message, yes_label="Yes", no_label="No"): # pylint: disable=missing-docstring + def generic_yesno(self, message, yes_label="Yes", no_label="No"): + # pylint: disable=missing-docstring return self.dialog.DIALOG_OK == self.dialog.yesno( message, self.height, self.width, yes_label=yes_label, no_label=no_label) @@ -72,7 +75,8 @@ class NcursesDisplay(CommonDisplayMixin): choices=choices) return code, [str(s) for s in names] - def success_installation(self, domains): # pylint: disable=missing-docstring + def success_installation(self, domains): + # pylint: disable=missing-docstring self.dialog.msgbox( "\nCongratulations! You have successfully enabled " + gen_https_names(domains) + "!", width=self.width) @@ -118,13 +122,15 @@ class FileDisplay(CommonDisplayMixin): super(FileDisplay, self).__init__() self.outfile = outfile - def generic_notification(self, message): # pylint: disable=missing-docstring + def generic_notification(self, message): + # pylint: disable=missing-docstring side_frame = '-' * 79 msg = textwrap.fill(message, 80) self.outfile.write("\n%s\n%s\n%s\n" % (side_frame, msg, side_frame)) raw_input("Press Enter to Continue") - def generic_menu(self, message, choices, input_text=""): # pylint: disable=missing-docstring + def generic_menu(self, message, choices, input_text=""): + # pylint: disable=missing-docstring # Can take either tuples or single items in choices list if choices and isinstance(choices[0], tuple): choices = ["%s - %s" % (c[0], c[1]) for c in choices] @@ -144,7 +150,8 @@ class FileDisplay(CommonDisplayMixin): return code, (selection - 1) - def generic_input(self, message): # pylint: disable=no-self-use,missing-docstring + def generic_input(self, message): + # pylint: disable=no-self-use,missing-docstring ans = raw_input("%s (Enter c to cancel)\n" % message) if ans.startswith('c') or ans.startswith('C'): @@ -152,7 +159,8 @@ class FileDisplay(CommonDisplayMixin): else: return OK, ans - def generic_yesno(self, message, unused_yes_label="", unused_no_label=""): # pylint: disable=missing-docstring + def generic_yesno(self, message, unused_yes_label="", unused_no_label=""): + # pylint: disable=missing-docstring self.outfile.write("\n%s\n" % textwrap.fill(message, 80)) ans = raw_input("y/n: ") return ans.startswith('y') or ans.startswith('Y') @@ -202,7 +210,8 @@ class FileDisplay(CommonDisplayMixin): return code, selection - def success_installation(self, domains): # pylint: disable=missing-docstring + def success_installation(self, domains): + # pylint: disable=missing-docstring side_frame = '*' * 79 msg = textwrap.fill("Congratulations! You have successfully " "enabled %s!" % gen_https_names(domains)) diff --git a/letsencrypt/client/revoker.py b/letsencrypt/client/revoker.py index 8573868eb..f8b75b39c 100644 --- a/letsencrypt/client/revoker.py +++ b/letsencrypt/client/revoker.py @@ -112,8 +112,7 @@ class Revoker(object): else: exit(0) - # pylint: disable=no-self-use - def remove_cert_key(self, cert): + def remove_cert_key(self, cert): # pylint: disable=no-self-use """Remove certificate and key. :param dict cert: Cert dict used throughout revocation diff --git a/letsencrypt/client/tests/apache/parser_test.py b/letsencrypt/client/tests/apache/parser_test.py index df0046ff5..453952a19 100644 --- a/letsencrypt/client/tests/apache/parser_test.py +++ b/letsencrypt/client/tests/apache/parser_test.py @@ -42,8 +42,7 @@ class ApacheParserTest(util.ApacheTest): file_path = os.path.join( self.config_path, "sites-available", "letsencrypt.conf") - # pylint: disable=protected-access - self.parser._parse_file(file_path) + self.parser._parse_file(file_path) # pylint: disable=protected-access # search for the httpd incl matches = self.parser.aug.match( diff --git a/letsencrypt/client/tests/auth_handler_test.py b/letsencrypt/client/tests/auth_handler_test.py index c5e97dace..b80c3c61d 100644 --- a/letsencrypt/client/tests/auth_handler_test.py +++ b/letsencrypt/client/tests/auth_handler_test.py @@ -17,7 +17,6 @@ TRANSLATE = { } -# pylint: disable=protected-access class SatisfyChallengesTest(unittest.TestCase): """verify_identities test.""" @@ -42,7 +41,7 @@ class SatisfyChallengesTest(unittest.TestCase): msg = acme_util.get_chall_msg(dom, "nonce0", challenge) self.handler.add_chall_msg(dom, msg, "dummy_key") - self.handler._satisfy_challenges() + self.handler._satisfy_challenges() # pylint: disable=protected-access self.assertEqual(len(self.handler.responses), 1) self.assertEqual(len(self.handler.responses[dom]), 1) @@ -61,7 +60,7 @@ class SatisfyChallengesTest(unittest.TestCase): acme_util.get_chall_msg(str(i), "nonce%d" % i, challenge), "dummy_key") - self.handler._satisfy_challenges() + self.handler._satisfy_challenges() # pylint: disable=protected-access self.assertEqual(len(self.handler.responses), 5) self.assertEqual(len(self.handler.dv_c), 5) @@ -90,7 +89,7 @@ class SatisfyChallengesTest(unittest.TestCase): path = gen_path(["simpleHttps"], challenges) mock_chall_path.return_value = path - self.handler._satisfy_challenges() + self.handler._satisfy_challenges() # pylint: disable=protected-access self.assertEqual(len(self.handler.responses), 1) self.assertEqual(len(self.handler.responses[dom]), len(challenges)) @@ -120,7 +119,7 @@ class SatisfyChallengesTest(unittest.TestCase): path = gen_path(["simpleHttps", "recoveryToken"], challenges) mock_chall_path.return_value = path - self.handler._satisfy_challenges() + self.handler._satisfy_challenges() # pylint: disable=protected-access self.assertEqual(len(self.handler.responses), 1) self.assertEqual(len(self.handler.responses[dom]), len(challenges)) @@ -151,7 +150,7 @@ class SatisfyChallengesTest(unittest.TestCase): path = gen_path(["dvsni", "recoveryContact"], challenges) mock_chall_path.return_value = path - self.handler._satisfy_challenges() + self.handler._satisfy_challenges() # pylint: disable=protected-access self.assertEqual(len(self.handler.responses), 5) for i in range(5): @@ -200,7 +199,7 @@ class SatisfyChallengesTest(unittest.TestCase): mock_chall_path.side_effect = paths - self.handler._satisfy_challenges() + self.handler._satisfy_challenges() # pylint: disable=protected-access self.assertEqual(len(self.handler.responses), 5) self.assertEqual(len(self.handler.dv_c), 5) diff --git a/letsencrypt/client/tests/challenge_util_test.py b/letsencrypt/client/tests/challenge_util_test.py index e0b99122f..759ee34ce 100644 --- a/letsencrypt/client/tests/challenge_util_test.py +++ b/letsencrypt/client/tests/challenge_util_test.py @@ -12,8 +12,9 @@ from letsencrypt.client import client from letsencrypt.client import CONFIG from letsencrypt.client import le_util -# pylint: disable=too-few-public-methods + class DvsniGenCertTest(unittest.TestCase): + # pylint: disable=too-few-public-methods """Tests for letsencrypt.client.challenge_util.dvsni_gen_cert.""" def test_standard(self):