From 4b9748a0c85a1ec8ed597f591104666af56ebf98 Mon Sep 17 00:00:00 2001
From: Einar Forselv <eforselv@gmail.com>
Date: Tue, 12 Nov 2019 12:39:49 +0100
Subject: [PATCH] pep8 and spelling errors

---
 restic_volume_backup/backup_runner.py |  6 ++----
 restic_volume_backup/cli.py           | 15 ++++++++-------
 restic_volume_backup/config.py        |  2 +-
 restic_volume_backup/containers.py    | 22 ++++++++++------------
 restic_volume_backup/restic.py        |  3 +--
 tests/tests.py                        |  2 +-
 6 files changed, 23 insertions(+), 27 deletions(-)

diff --git a/restic_volume_backup/backup_runner.py b/restic_volume_backup/backup_runner.py
index 6c9b87a..777b727 100644
--- a/restic_volume_backup/backup_runner.py
+++ b/restic_volume_backup/backup_runner.py
@@ -1,13 +1,11 @@
 import os
-import sys
-import time
 import docker
 
 from restic_volume_backup.config import Config
 
 
 def run(image: str = None, command: str = None, volumes: dict = None,
-    enviroment: dict = None, labels: dict = None):
+        environment: dict = None, labels: dict = None):
     config = Config()
     client = docker.DockerClient(base_url=config.docker_base_url)
 
@@ -17,7 +15,7 @@ def run(image: str = None, command: str = None, volumes: dict = None,
         labels=labels,
         # auto_remove=True,
         detach=True,
-        environment=enviroment,
+        environment=environment,
         volumes=volumes,
         working_dir=os.getcwd(),
         tty=True,
diff --git a/restic_volume_backup/cli.py b/restic_volume_backup/cli.py
index d0380e3..1ccde04 100644
--- a/restic_volume_backup/cli.py
+++ b/restic_volume_backup/cli.py
@@ -1,6 +1,5 @@
 import argparse
 import pprint
-import sys
 
 from restic_volume_backup.config import Config
 from restic_volume_backup.containers import RunningContainers
@@ -25,12 +24,12 @@ def main():
 
 
 def status(config, containers):
-    """Outputs the backup config for the compse setup"""
+    """Outputs the backup config for the compose setup"""
     print()
     print("Backup config for compose project '{}'".format(containers.this_container.project_name))
     print("Current service:", containers.this_container.name)
-    print("Backup process :", containers.backup_process_container.name \
-        if containers.backup_process_container else 'Not Running')
+    print("Backup process :", containers.backup_process_container.name
+          if containers.backup_process_container else 'Not Running')
     print("Backup running :", containers.backup_process_running)
 
     print()
@@ -52,7 +51,7 @@ def backup(config, containers):
     """Start backup"""
     # Make sure we don't spawn multiple backup processes
     if containers.backup_process_running:
-        raise ValueError("Backup process already running")        
+        raise ValueError("Backup process already running")
 
     print("Initializing repository")
 
@@ -73,7 +72,7 @@ def backup(config, containers):
         image=containers.this_container.image,
         command='restic-volume-backup start-backup-process',
         volumes=volumes,
-        enviroment=containers.this_container.environment,
+        environment=containers.this_container.environment,
         labels={
             "restic-volume-backup.backup_process": 'True',
             "com.docker.compose.project": containers.this_container.project_name,
@@ -83,7 +82,8 @@ def backup(config, containers):
 
 def start_backup_process(config, containers):
     """Start the backup process container"""
-    if not containers.backup_process_container or containers.this_container == containers.backup_process_container is False:
+    if (not containers.backup_process_container
+       or containers.this_container == containers.backup_process_container is False):
         print(
             "Cannot run backup process in this container. Use backup command instead. "
             "This will spawn a new container with the necessary mounts."
@@ -99,6 +99,7 @@ def start_backup_process(config, containers):
 
     exit(1)
 
+
 def parse_args():
     parser = argparse.ArgumentParser(prog='restic_volume_backup')
     parser.add_argument(
diff --git a/restic_volume_backup/config.py b/restic_volume_backup/config.py
index 10ee3d2..b86efa6 100644
--- a/restic_volume_backup/config.py
+++ b/restic_volume_backup/config.py
@@ -6,7 +6,7 @@ class Config:
         self.repository = os.environ['RESTIC_REPOSITORY']
         self.password = os.environ['RESTIC_PASSWORD']
         self.docker_base_url = os.environ.get('DOCKER_BASE_URL') or "unix://tmp/docker.sock"
-    
+
         if check:
             self.check()
 
diff --git a/restic_volume_backup/containers.py b/restic_volume_backup/containers.py
index e303212..802055e 100644
--- a/restic_volume_backup/containers.py
+++ b/restic_volume_backup/containers.py
@@ -1,7 +1,4 @@
 import os
-import docker
-import json
-import pprint
 
 from restic_volume_backup import utils
 
@@ -28,7 +25,7 @@ class Container:
 
         self._labels = self._config.get('Labels')
         if self._labels is None:
-            raise ValueError('Container mtea missing Config->Labels')
+            raise ValueError('Container meta missing Config->Labels')
 
         self._include = self._parse_pattern(self.get_label('restic-volume-backup.include'))
         self._exclude = self._parse_pattern(self.get_label('restic-volume-backup.exclude'))
@@ -43,7 +40,7 @@ class Container:
         """All configured env vars for the container"""
         return self.get_config('Env', default=[])
 
-    property
+    @property
     def volumes(self):
         """
         Return volumes for the container in the following format:
@@ -90,7 +87,7 @@ class Container:
         return self._state.get('Running', False)
 
     @property
-    def service_name(self) ->str:
+    def service_name(self) -> str:
         """Name of the container/service"""
         return self.get_label('com.docker.compose.service', default='')
 
@@ -189,7 +186,7 @@ class Mount:
 
     @property
     def name(self) -> str:
-        """Name of the mount"""        
+        """Name of the mount"""
         return self._data.get('Name')
 
     @property
@@ -199,7 +196,7 @@ class Mount:
 
     @property
     def destination(self) -> str:
-        """Destionatin path for the volume mount in the container"""
+        """Destination path for the volume mount in the container"""
         return self._data.get('Destination')
 
     def __repr__(self) -> str:
@@ -209,13 +206,13 @@ class Mount:
         return str(self._data)
 
     def __hash__(self):
-        """Uniquness for a volume"""
+        """Uniqueness for a volume"""
         if self.type == VOLUME_TYPE_VOLUME:
             return hash(self.name)
         elif self.type == VOLUME_TYPE_BIND:
             return hash(self.source)
         else:
-            raise ValueError("Uknown volume type: {}".format(self.type))
+            raise ValueError("Unknown volume type: {}".format(self.type))
 
 
 class RunningContainers:
@@ -243,8 +240,9 @@ class RunningContainers:
             if container.is_backup_process_container:
                 self.backup_process_container = container
 
-            # Detect containers beloging to the current compose setup
-            if container.project_name == self.this_container.project_name and not container.is_oneoff:
+            # Detect containers belonging to the current compose setup
+            if (container.project_name == self.this_container.project_name
+               and not container.is_oneoff):
                 if container.id != self.this_container.id:
                     self.containers.append(container)
 
diff --git a/restic_volume_backup/restic.py b/restic_volume_backup/restic.py
index c74b081..ba724f7 100644
--- a/restic_volume_backup/restic.py
+++ b/restic_volume_backup/restic.py
@@ -1,5 +1,4 @@
-import os
-from subprocess import Popen, PIPE, check_call
+from subprocess import Popen, PIPE
 
 
 def init_repo(repository):
diff --git a/tests/tests.py b/tests/tests.py
index 37d999e..b32f13b 100644
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -14,7 +14,7 @@ class ResticBackupTests(unittest.TestCase):
 
     @classmethod
     def setUpClass(cls):
-        """Set up basic enviroment variables"""
+        """Set up basic environment variables"""
         os.environ['RESTIC_REPOSITORY'] = "test"
         os.environ['RESTIC_PASSWORD'] = "password"