← Back to team overview

duplicity-team team mailing list archive

[Merge] lp:~aaron-whitehouse/duplicity/08-style-fixes into lp:duplicity

 

Aaron Whitehouse has proposed merging lp:~aaron-whitehouse/duplicity/08-style-fixes into lp:duplicity.

Commit message:
* Fix pylint style issues (over-indented text, whitespace on blank lines etc)
* Removed "pylint: disable=bad-string-format-type" comment, which was throwing an error and does not seem to be needed.

Requested reviews:
  duplicity-team (duplicity-team)

For more details, see:
https://code.launchpad.net/~aaron-whitehouse/duplicity/08-style-fixes/+merge/364218
-- 
Your team duplicity-team is requested to review the proposed merge of lp:~aaron-whitehouse/duplicity/08-style-fixes into lp:duplicity.
=== modified file 'duplicity/asyncscheduler.py'
--- duplicity/asyncscheduler.py	2018-11-29 19:00:15 +0000
+++ duplicity/asyncscheduler.py	2019-03-10 23:03:36 +0000
@@ -241,18 +241,18 @@
         thread.start_new_thread(trampoline, ())
 
     def __execute_caller(self, caller):
-            # The caller half that we get here will not propagate
-            # errors back to us, but rather propagate it back to the
-            # "other half" of the async split.
-            succeeded, waiter = caller()
-            if not succeeded:
-                def _signal_failed():
-                    if not self.__failed:
-                        self.__failed = True
-                        self.__failed_waiter = waiter
-                        self.__cv.notifyAll()
-                with_lock(self.__cv, _signal_failed)
+        # The caller half that we get here will not propagate
+        # errors back to us, but rather propagate it back to the
+        # "other half" of the async split.
+        succeeded, waiter = caller()
+        if not succeeded:
+            def _signal_failed():
+                if not self.__failed:
+                    self.__failed = True
+                    self.__failed_waiter = waiter
+                    self.__cv.notifyAll()
+            with_lock(self.__cv, _signal_failed)
 
-            log.Info(u"%s: %s" % (self.__class__.__name__,
-                     _(u"task execution done (success: %s)") % succeeded),
-                     log.InfoCode.asynchronous_upload_done)
+        log.Info(u"%s: %s" % (self.__class__.__name__,
+                 _(u"task execution done (success: %s)") % succeeded),
+                 log.InfoCode.asynchronous_upload_done)

=== modified file 'duplicity/backends/azurebackend.py'
--- duplicity/backends/azurebackend.py	2019-01-01 21:36:27 +0000
+++ duplicity/backends/azurebackend.py	2019-03-10 23:03:36 +0000
@@ -102,7 +102,7 @@
             # fallback for azure-storage<0.30.0
             except AttributeError:
                 self.blob_service._BLOB_MAX_CHUNK_DATA_SIZE = globals.azure_max_block_size
-                
+
     def _create_container(self):
         try:
             self.blob_service.create_container(self.container, fail_on_exist=True)
@@ -124,16 +124,16 @@
             self.blob_service.create_blob_from_path(self.container, remote_filename, source_path.name, **kwargs)
         except AttributeError:  # Old versions use a different method name
             self.blob_service.put_block_blob_from_path(self.container, remote_filename, source_path.name, **kwargs)
-        
+
         self._set_tier(remote_filename)
-            
+
     def _set_tier(self, remote_filename):
         if globals.azure_blob_tier is not None:
             try:
                 self.blob_service.set_standard_blob_tier(self.container, remote_filename, globals.azure_blob_tier)
             except AttributeError:  # might not be available in old API
                 pass
-            
+
     def _get(self, remote_filename, local_path):
         # https://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-blob-storage/#download-blobs
         self.blob_service.get_blob_to_path(self.container, remote_filename, local_path.name)

=== modified file 'duplicity/backends/b2backend.py'
--- duplicity/backends/b2backend.py	2018-12-27 16:43:07 +0000
+++ duplicity/backends/b2backend.py	2019-03-10 23:03:36 +0000
@@ -38,7 +38,7 @@
 class B2ProgressListener:
     def __enter__(self):
         pass
-    
+
     def set_total_bytes(self, total_byte_count):
         self.total_byte_count = total_byte_count
 
@@ -51,6 +51,7 @@
     def __exit__(self, exc_type, exc_val, exc_tb):
         pass
 
+
 class B2Backend(duplicity.backend.Backend):
     u"""
     Backend for BackBlaze's B2 storage service

=== modified file 'duplicity/backends/webdavbackend.py'
--- duplicity/backends/webdavbackend.py	2018-12-23 16:52:31 +0000
+++ duplicity/backends/webdavbackend.py	2019-03-10 23:03:36 +0000
@@ -57,76 +57,76 @@
 
 
 class VerifiedHTTPSConnection(http.client.HTTPSConnection):
-        def __init__(self, *args, **kwargs):
-            try:
-                global socket, ssl
-                import socket
-                import ssl
-            except ImportError:
-                raise FatalBackendException(_(u"Missing socket or ssl python modules."))
-
-            http.client.HTTPSConnection.__init__(self, *args, **kwargs)
-
-            self.cacert_file = globals.ssl_cacert_file
-            self.cacert_candidates = [u"~/.duplicity/cacert.pem",
-                                      u"~/duplicity_cacert.pem",
-                                      u"/etc/duplicity/cacert.pem"]
-            # if no cacert file was given search default locations
+    def __init__(self, *args, **kwargs):
+        try:
+            global socket, ssl
+            import socket
+            import ssl
+        except ImportError:
+            raise FatalBackendException(_(u"Missing socket or ssl python modules."))
+
+        http.client.HTTPSConnection.__init__(self, *args, **kwargs)
+
+        self.cacert_file = globals.ssl_cacert_file
+        self.cacert_candidates = [u"~/.duplicity/cacert.pem",
+                                  u"~/duplicity_cacert.pem",
+                                  u"/etc/duplicity/cacert.pem"]
+        # if no cacert file was given search default locations
+        if not self.cacert_file:
+            for path in self.cacert_candidates:
+                path = os.path.expanduser(path)
+                if (os.path.isfile(path)):
+                    self.cacert_file = path
+                    break
+
+        # check if file is accessible (libssl errors are not very detailed)
+        if self.cacert_file and not os.access(self.cacert_file, os.R_OK):
+            raise FatalBackendException(_(u"Cacert database file '%s' is not readable.") %
+                                        self.cacert_file)
+
+    def connect(self):
+        # create new socket
+        sock = socket.create_connection((self.host, self.port),
+                                        self.timeout)
+        if self._tunnel_host:
+            self.sock = sock
+            self.tunnel()
+
+        # python 2.7.9+ supports default system certs now
+        if u"create_default_context" in dir(ssl):
+            context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH,
+                                                 cafile=self.cacert_file,
+                                                 capath=globals.ssl_cacert_path)
+            self.sock = context.wrap_socket(sock, server_hostname=self.host)
+        # the legacy way needing a cert file
+        else:
+            if globals.ssl_cacert_path:
+                raise FatalBackendException(
+                    _(u"Option '--ssl-cacert-path' is not supported "
+                      u"with python 2.7.8 and below."))
+
             if not self.cacert_file:
-                for path in self.cacert_candidates:
-                    path = os.path.expanduser(path)
-                    if (os.path.isfile(path)):
-                        self.cacert_file = path
-                        break
-
-            # check if file is accessible (libssl errors are not very detailed)
-            if self.cacert_file and not os.access(self.cacert_file, os.R_OK):
-                raise FatalBackendException(_(u"Cacert database file '%s' is not readable.") %
-                                            self.cacert_file)
-
-        def connect(self):
-            # create new socket
-            sock = socket.create_connection((self.host, self.port),
-                                            self.timeout)
-            if self._tunnel_host:
-                self.sock = sock
-                self.tunnel()
-
-            # python 2.7.9+ supports default system certs now
-            if u"create_default_context" in dir(ssl):
-                context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH,
-                                                     cafile=self.cacert_file,
-                                                     capath=globals.ssl_cacert_path)
-                self.sock = context.wrap_socket(sock, server_hostname=self.host)
-            # the legacy way needing a cert file
-            else:
-                if globals.ssl_cacert_path:
-                    raise FatalBackendException(
-                        _(u"Option '--ssl-cacert-path' is not supported "
-                          u"with python 2.7.8 and below."))
-
-                if not self.cacert_file:
-                    raise FatalBackendException(_(u"""\
+                raise FatalBackendException(_(u"""\
 For certificate verification with python 2.7.8 or earlier a cacert database
 file is needed in one of these locations: %s
 Hints:
-  Consult the man page, chapter 'SSL Certificate Verification'.
-  Consider using the options --ssl-cacert-file, --ssl-no-check-certificate .""") %
-                                                u", ".join(self.cacert_candidates))
-
-                # wrap the socket in ssl using verification
-                self.sock = ssl.wrap_socket(sock,
-                                            cert_reqs=ssl.CERT_REQUIRED,
-                                            ca_certs=self.cacert_file,
-                                            )
-
-        def request(self, *args, **kwargs):  # pylint: disable=method-hidden
-            try:
-                return http.client.HTTPSConnection.request(self, *args, **kwargs)
-            except ssl.SSLError as e:
-                # encapsulate ssl errors
-                raise BackendException(u"SSL failed: %s" % util.uexc(e),
-                                       log.ErrorCode.backend_error)
+Consult the man page, chapter 'SSL Certificate Verification'.
+Consider using the options --ssl-cacert-file, --ssl-no-check-certificate .""") %
+                                            u", ".join(self.cacert_candidates))
+
+            # wrap the socket in ssl using verification
+            self.sock = ssl.wrap_socket(sock,
+                                        cert_reqs=ssl.CERT_REQUIRED,
+                                        ca_certs=self.cacert_file,
+                                        )
+
+    def request(self, *args, **kwargs):  # pylint: disable=method-hidden
+        try:
+            return http.client.HTTPSConnection.request(self, *args, **kwargs)
+        except ssl.SSLError as e:
+            # encapsulate ssl errors
+            raise BackendException(u"SSL failed: %s" % util.uexc(e),
+                                   log.ErrorCode.backend_error)
 
 
 class WebDAVBackend(duplicity.backend.Backend):

=== modified file 'duplicity/collections.py'
--- duplicity/collections.py	2019-02-22 20:25:02 +0000
+++ duplicity/collections.py	2019-03-10 23:03:36 +0000
@@ -1096,8 +1096,8 @@
             if (chain.end_time < t and
                 (not self.matched_chain_pair or
                  chain is not self.matched_chain_pair[1])):
-                    # don't delete the active (matched) chain
-                    old_chains.append(chain)
+                # don't delete the active (matched) chain
+                old_chains.append(chain)
         return old_chains
 
     def get_signature_chains_older_than(self, t):
@@ -1116,8 +1116,8 @@
             if (chain.end_time < t and
                 (not self.matched_chain_pair or
                  chain is not self.matched_chain_pair[0])):
-                    # don't delete the active (matched) chain
-                    old_chains.append(chain)
+                # don't delete the active (matched) chain
+                old_chains.append(chain)
         return old_chains
 
     def get_last_full_backup_time(self):

=== modified file 'duplicity/statistics.py'
--- duplicity/statistics.py	2019-02-22 19:04:51 +0000
+++ duplicity/statistics.py	2019-03-10 23:03:36 +0000
@@ -156,10 +156,10 @@
         u"""Return portion of statistics string dealing with time"""
         timelist = []
         if self.StartTime is not None:
-            timelist.append(u"StartTime %.2f (%s)\n" %  # pylint: disable=bad-string-format-type
+            timelist.append(u"StartTime %.2f (%s)\n" %
                             (self.StartTime, dup_time.timetopretty(self.StartTime)))
         if self.EndTime is not None:
-            timelist.append(u"EndTime %.2f (%s)\n" %  # pylint: disable=bad-string-format-type
+            timelist.append(u"EndTime %.2f (%s)\n" %
                             (self.EndTime, dup_time.timetopretty(self.EndTime)))
         if self.ElapsedTime or (self.StartTime is not None and
                                 self.EndTime is not None):


Follow ups