Browse Source

use builtin NotImplementedError instead of writing our own

NotImplemented didn't work with pytest.raise(), i didn't know about NotImplementedError, thanks tw
Antoine Beaupré 9 years ago
parent
commit
d66516351f
3 changed files with 5 additions and 8 deletions
  1. 2 2
      borg/archiver.py
  2. 1 4
      borg/converter.py
  3. 2 2
      borg/testsuite/convert.py

+ 2 - 2
borg/archiver.py

@@ -17,7 +17,7 @@ import traceback
 from . import __version__
 from . import __version__
 from .archive import Archive, ArchiveChecker, CHUNKER_PARAMS
 from .archive import Archive, ArchiveChecker, CHUNKER_PARAMS
 from .compress import Compressor, COMPR_BUFFER
 from .compress import Compressor, COMPR_BUFFER
-from .converter import AtticRepositoryConverter, NotImplementedException
+from .converter import AtticRepositoryConverter
 from .repository import Repository
 from .repository import Repository
 from .cache import Cache
 from .cache import Cache
 from .key import key_creator
 from .key import key_creator
@@ -468,7 +468,7 @@ Type "Yes I am sure" if you understand this and want to continue.\n""")
         repo = AtticRepositoryConverter(os.path.join(args.repository, 'repository'), create=False)
         repo = AtticRepositoryConverter(os.path.join(args.repository, 'repository'), create=False)
         try:
         try:
             repo.convert(args.dry_run)
             repo.convert(args.dry_run)
-        except NotImplementedException as e:
+        except NotImplementedError as e:
             print("warning: %s" % e)
             print("warning: %s" % e)
         return self.exit_code
         return self.exit_code
 
 

+ 1 - 4
borg/converter.py

@@ -5,9 +5,6 @@ from .helpers import get_keys_dir
 from .repository import Repository, MAGIC
 from .repository import Repository, MAGIC
 from .key import KeyfileKey, KeyfileNotFoundError
 from .key import KeyfileKey, KeyfileNotFoundError
 
 
-class NotImplementedException(Exception):
-    pass
-
 class AtticRepositoryConverter(Repository):
 class AtticRepositoryConverter(Repository):
     def convert(self, dryrun=True):
     def convert(self, dryrun=True):
         """convert an attic repository to a borg repository
         """convert an attic repository to a borg repository
@@ -108,7 +105,7 @@ class AtticRepositoryConverter(Repository):
           `Cache.open()`, edit in place and then `Cache.close()` to
           `Cache.open()`, edit in place and then `Cache.close()` to
           make sure we have locking right
           make sure we have locking right
         """
         """
-        raise NotImplementedException('cache conversion not implemented, next borg backup will take longer to rebuild those caches')
+        raise NotImplementedError('cache conversion not implemented, next borg backup will take longer to rebuild those caches')
 
 
 class AtticKeyfileKey(KeyfileKey):
 class AtticKeyfileKey(KeyfileKey):
     """backwards compatible Attic key file parser"""
     """backwards compatible Attic key file parser"""

+ 2 - 2
borg/testsuite/convert.py

@@ -12,7 +12,7 @@ except ImportError:
 pytestmark = pytest.mark.skipif(attic is None,
 pytestmark = pytest.mark.skipif(attic is None,
                                 reason = 'cannot find an attic install')
                                 reason = 'cannot find an attic install')
 
 
-from ..converter import AtticRepositoryConverter, NotImplementedException, AtticKeyfileKey
+from ..converter import AtticRepositoryConverter, AtticKeyfileKey
 from ..helpers import get_keys_dir
 from ..helpers import get_keys_dir
 from ..key import KeyfileKey
 from ..key import KeyfileKey
 from ..repository import Repository, MAGIC
 from ..repository import Repository, MAGIC
@@ -87,7 +87,7 @@ class EncryptedConversionTestCase(ConversionTestCase):
         # check should fail because of magic number
         # check should fail because of magic number
         self.check_repo(False)
         self.check_repo(False)
         print("opening attic repository with borg and converting")
         print("opening attic repository with borg and converting")
-        with pytest.raises(NotImplementedException):
+        with pytest.raises(NotImplementedError):
             self.open(self.tmppath, repo_type = AtticRepositoryConverter).convert(dryrun=False)
             self.open(self.tmppath, repo_type = AtticRepositoryConverter).convert(dryrun=False)
         # check that the new keyfile is alright
         # check that the new keyfile is alright
         keyfile = os.path.join(get_keys_dir(),
         keyfile = os.path.join(get_keys_dir(),